On my website, I've got a div at the bottom which is basically just an image that changes when you put your mouse over it:
Before mouseover:

On mouseover:

I want a sound to play when you click it.
I found a way to do this using javascript.
Here's the script:
<script language="javascript" type="text/javascript">
function playSound(soundfile) {
document.getElementById("dummy").innerHTML=
"<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
}
</script>
and here's the code for the images (including the mouseclick code to play the sound):
<span id="dummy" onclick="playSound('images/where.mp3');"><a onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Bottom-1','','images/dateover.png',1)"><img src="images/date.png" name="Bottom-1" width="115" height="45" border="0" id="Bottom-1" /></a></span>
When I click the image, the sound plays but it also gets rid of the images:

This happens to everything that I try and use the sound on. For example, if I tried to click one word in <SPAN> tags, the sound would play but the word would disappear.
Is there a way to stop stuff disappearing when I want the sound to play?
Thanks.


Sign In
Create Account


Back to top









