Playing Sound onMouseOver

JavaScript FAQ | JavaScript Sound FAQ  

Question: Can I play a sound onMouseOver?

Answer: Yes, you can call a sound playback function from the onMouseOver event handler of a hyperlink. Try this example: place your mouse pointer over the following hyperlink, and the browser will start the playback.

 J.S.Bach's Orchestral Suite BWV1067 - Badinerie 

Here's the source code for this hyperlink:

<a href=# 
title="This hyperlink plays a sound onMouseOver."
onClick="return false"
onMouseOver="playSound('Bach.mid');return true"
onMouseOut ="stopSound();return true"
>&nbsp;J.S.Bach's Orchestral Suite 
BWV1067 - Badinerie&nbsp;</a>
The source code of the functions playSound() and stopSound() can be found in the Playing Sound section.

See also:

  • How do I write a JavaScript function that plays a sound file?
  • Can I play a sound file without using JavaScript?
  • Copyright © 1999-2008,