I have looked on Google, and everywhere in the forums. Just learning JavaScript, so any help is appreciated. When I put .wav in the parameters it says error, don’t know if that makes a difference anyway.
In the head:
<script type="text/javascript">
function playSound(cellowav) {
document.getElementById("dummy").innerHTML=
"<embeded src=\""+cellowav.wav+"\" hidden=\"true\" loop=\"false\" />
}
</script>
In the body:
<span id="dummy"></span>
<p onmouseover="playsound('cellowav.wav');">
<img src="smiley.png" border="0" alt="smiley" />
</p>
Okay, I found that yes the cellowav doesn’t belong in the parameter, or the string and the sound will play automatically with the embed tag in html. I was missing the closing -"- in the string fixed that. Changed the functions parameters from (cellowav) to (soundfile) and in the string + cellowav + to
-
soundfile +.
<script language="javascript" type="text/javascript"> function playSound(soundfile) { document.getElementById("dummy").innerHTML= "<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />"; } </script> <span id="dummy"></span> <p onmouseover="playSound('cellowav.wav');"><img src="smiley.png" alt="smiley"></p>
You’re missing a
"at the end ofinnerHTML=...in your function.Furthermore you can’t include
cellowav.wavthat way. You need to put in the url to the file there.Should be looking something like this: