jazzylee77
Dec 25th 2008, 7:14 pm
I'm doing something funny on a page. I've got it so when you click a link it plays a sound.
Using this code in the head
<script language="javascript" type="text/javascript">
function playSound(soundfile) {
document.getElementById("dummy").innerHTML=
"<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
}
</script>
a dummy span on the page <span id="dummy"></span>
and this to call it <a href="#" onclick="playSound('path to soundfile');">Click here</a>
So far so good. Now I would like to make play a random sound.
Using this code in the head
<script language="javascript" type="text/javascript">
function playSound(soundfile) {
document.getElementById("dummy").innerHTML=
"<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
}
</script>
a dummy span on the page <span id="dummy"></span>
and this to call it <a href="#" onclick="playSound('path to soundfile');">Click here</a>
So far so good. Now I would like to make play a random sound.