Solved

Launching a .wav with a mouseclick

Posted on 1997-05-20
2
298 Views
Last Modified: 2012-08-14
Okay, this shouldn't be too difficult. I just need another idea how to do it most effectively.  I need to play a short .wav file when someone clicks on a link (this is an image, and I will be using 'onclick= ...'  but I don't want to have it open a new window every time. Should I create a frame with a size of 0,0 and target the .wav there?  Or is there a way to make it play without bringin' up a new window. I was hoping for something like "onclick=PlaySound("soundfile.wav");return true;"
Any suggestions? I'll make this one 100 points, as I am anxious for a response, and I was hoping for a really clean method that would work on netscape and explorer both. :)
0
Comment
Question by:jvoisin
2 Comments
 
LVL 5

Accepted Solution

by:
Trevor013097 earned 100 total points
ID: 1265614
Okay try this:-

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<SCRIPT LANGUAGE="JavaScript">
function start()
{
document.the-name.play(false);
}
</SCRIPT>


<BODY>

<EMBED SRC="filename.wav" HIDDEN=TRUE AUTOSTART=FALSE NAME="the-name" MASTERSOUND>

<a href="JavaScript:start();">Start Music</A>

</BODY>

</HTML>


This simply changes the play property of the embedded sound when you click on the link.
0
 

Author Comment

by:jvoisin
ID: 1265615
But, if you try this with Internet Exploder, you will get 'Object dosen't support this property or method' I was hoping for a method that works with both Netscape and MSIE..

(BTW I did it with MSIE 3.02 and 4.0 both are a no-go)

....
function start(){document.BING.play(false);}</SCRIPT>
<BODY>
....
<EMBED SRC="bing.wav" HIDDEN=TRUE AUTOSTART=FALSE NAME="BING" MASTERSOUND>
....
<a href="javascript:parent.frames[1].history.go(-1)"
  onmouseover="ImgFunc('button1','button1n');showInfo('Go Back One Page');return true;"
  onmouseout="ImgFunc('button1','button1');clearInfo();return true;"
  onclick="start();return true;"
  target ="MD_Page">
...


Everything works awesome in Netscape though, and I think that's 70% or more...

I'll just make it so that the script won't run with exploder.

Thanks alot..  If you think of another way that explorer won't choke on, let me know.  :)

Awesome speed on the answer BTW, less than an hour, I bet the newsgroups would have taken a week at least.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now