I think this code should play a sound, then show an alert box. It works with IE9, but with Chrome & Firefox, the sound is played, but the callback is never called - so no alert box.
I'm a c#, c++ programmer new to javascript, and I could use some help! Thanks.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script type="text/javascript">
var playAll= function(){
var audio = document.getElementById('s');
var callback = function(e){
alert("ended");
};
audio.onended = callback;
audio.play();
}
</script>
</head>
<body>
<input name="Button1" type="button" value="Play" onclick="playAll()"/>
<audio ID="s">
<source src="s.mp3" >
<source src="s.ogg" >
</body>
</html>