954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Trying to get a javascript function to play a sound

Hey, I am trying to get a sound to play when the user moves the mouse over on of my links. I don't know javascript, I just copied this code from a book, so it's probably something simple. Here is my code:

<script language="JavaScript" type="text/javascript">
      function playSound()
      {
      src="misc020.wav";
      }
</script>

<A HREF="http://www.newhorizondesigns.org" onMouseOver="playSound()">Home</A></td>
adaykin
Junior Poster in Training
73 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

That's weird looking script. I can't see any way that it could work - in that context; 'src' wont relate to anything useful.

This page has some example code (lots of examples); it won't work for me; but I'm not on a computer with many media plugins:

http://www.phon.ucl.ac.uk/home/mark/audio/play.htm

Hope that helps some...

MattEvans
Veteran Poster
Moderator
1,386 posts since Jul 2006
Reputation Points: 522
Solved Threads: 64
 

http://www.javascriptkit.com/script/script2/soundlink.shtml

don't forget to do a onmouseout=stop or it'll carry on going

hbk619
Master Poster
733 posts since Oct 2006
Reputation Points: 273
Solved Threads: 8
 
nhlarry
Newbie Poster
3 posts since Mar 2007
Reputation Points: 10
Solved Threads: 0
 

the java script doesnt work ... can v include some other class or script to run music in web page or ... some other thing to do ??????

smartguynrj
Newbie Poster
3 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 

That's weird looking script. I can't see any way that it could work - in that context; 'src' wont relate to anything useful.

This page has some example code (lots of examples); it won't work for me; but I'm not on a computer with many media plugins:

http://www.phon.ucl.ac.uk/home/mark/audio/play.htm

Hope that helps some...

thanks I used #4 on that list, and it works, check it out, the links on the left side of the page are where it is designed to play: http://www.newhorizondesigns.org

adaykin
Junior Poster in Training
73 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

pretty sweet8, even if my IE blocked the WMP active x to start with ;)

hbk619
Master Poster
733 posts since Oct 2006
Reputation Points: 273
Solved Threads: 8
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You