onended = myFunction(); - Javascript DOM Event

Javascript examples for DOM Event:Element Event Attribute

Description

The onended event occurs when the audio/video has reached the end.

Summary

Bubbles No
Cancelable No
Supported HTML tags: <audio> and <video>

Demo Code

ResultView the demo in separate window

<!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>//from   w w w  .jav a 2  s .  c  o  m

<p id="demo"></p>

<script>
document.getElementById("myAudio").onended = function() {myFunction()};

function myFunction() {
    document.getElementById("demo").innerHTML = "The audio has ended.";
}
</script>

</body>
</html>

Related Tutorials