So I've got some buttons, which people can press to hear audio files. Of course, the audio files can't "overlap" because that would be a mess. This works, but now I want one of the files to play automatically when the website loads, still maintaining the fact that it will stop whenever I press another button.
This is what I've got so far:
Head:
<script language="javascript" type="text/javascript">
function playSound(soundfile) {
document.getElementById("dummy").innerHTML=
"<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"false\" loop=\"true\" />";
}
</script>
Body:
<span id="dummy"></span>
<p style="text-align:center;">
<a href="#" onclick="playSound('Sound1.mp3');">
<img class="alignnone" width="128" img src="Img1.png" ></a>
<a href="#" onclick="playSound('Sound2.mp3');">
<img class="alignnone" width="128" img src="Img2.png" ></a>
<a href="#" onclick="playSound('Sound3.mp3');">
<img class="alignnone" width="128" img src="Img3.png" ></a>
</p>