Hi, how can I play a sound when a user moves his/her mouse over a link on my website. I'm already using a ONMOUSEOVER for a rollover. Is it possible to add two ONMOUSEOVERs?
How can I play the sound when the link is clicked?
Printable View
Hi, how can I play a sound when a user moves his/her mouse over a link on my website. I'm already using a ONMOUSEOVER for a rollover. Is it possible to add two ONMOUSEOVERs?
How can I play the sound when the link is clicked?
Script:
Link:Code:function playSound(SName)
{
if (document.embeds[SName] != null && document.embeds[SName].IsReady())
{
document.embeds[SName].play(false)
}
}
You also need to put this on your page:Code:<a href="somewhere.html" onMouseOver="playSound('snd1');otherMouseOver()">
Edit: Doesn't seem to work in IE, i got it from http://www.chalcedony.com/.Code:<embed src="snd1.wav" name="snd1" hidden="true" loop="false" autostart="false">
IE 4+
Taken from http://www.javascriptcity.com
Code:<EMBED SRC="sound_file_name.wav" autostart="false" hidden="true">
<SCRIPT language="JavaScript">
<!--
function playHome()
{
if (document.all)
{
document.all.sound.src = "sound_file_name.wav";
}
}
//-->
</SCRIPT>
<bgsound id="sound">
Put your mouse on the link to hear a sound
<A HREF="http://yoursite.com/page.html" onMouseover="playHome()">HERE</A>