Javascript examples for DOM Event:addEventListener
The onended event occurs when the audio/video has reached the end.
Bubbles | No |
---|---|
Cancelable | No |
Supported HTML tags: | <audio> and <video> |
<!DOCTYPE html> <html> <body> <audio id="myAudio" controls> <source src="your.ogg" type="audio/ogg"> <source src="your.mp3" type="audio/mpeg"> Your browser does not support the audio element. </audio>// ww w . ja v a 2 s. c o m <p id="demo"></p> <script> document.getElementById("myAudio").addEventListener("ended", myFunction); function myFunction() { document.getElementById("demo").innerHTML = "The audio has ended."; } </script> </body> </html>