HTML Audio / Video DOM ended event
HTML Audio / Video DOM Reference
Examples
After the completion of the audio player pop-up message:
var aud = document.getElementById ( "myAudio");
aud.onended = function () {
alert ( "complete audio player");
};
aud.onended = function () {
alert ( "complete audio player");
};
try it"
Bottom of this article contains more examples.
Definition and Usage
It ended the event in the audio / video (audio / video) trigger after playback is done.
This event is often used to prompt the player to complete the information, such as "Thank you for listening," "Thank you for watching" and so on.
Browser Support
Figures in the table represent the first browser to support this version of events.
event | |||||
---|---|---|---|---|---|
ended | Yes | 9.0 | Yes | Yes | Yes |
grammar
In HTML:
<Audio | video onended = "myScript "> try
In JavaScript:
audio | video .onended = function () {myScript}; try
JavaScript, use the addEventListener () method:
audio | video .addEventListener ( "ended" , myScript); try
Note: Internet Explorer 8 and earlier versions of IE browser does not support addEventListener () method.
technical details
Supported HTML tags: | <Audio> and <video> |
---|---|
Supported JavaScript Objects: | Audio, Video |
More examples
Examples
After the completion of the video player pop-up message:
var vid = document.getElementById ( "myVideo");
vid.onended = function () {
alert ( "The video has ended");
};
vid.onended = function () {
alert ( "The video has ended");
};
try it"
HTML Audio / Video DOM Reference