• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 323
  • Last Modified:

Launching a .wav with a mouseclick

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
jvoisin
Asked:
jvoisin
1 Solution
 
Trevor013097Commented:
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
 
jvoisinAuthor Commented:
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now