onendedEvent
Example
Execute JavaScript after the audio has finished playing:
<audio onended="myFunction()">
Try it Yourself »
More examples are included at the bottom of this article.
Definition and Usage
The onended event is triggered when the playback of a video/audio (audio/video) has ended.
This event is often used to display messages like "Thanks for watching".
Browser Support
The numbers in the table specify the first browser version that fully supports the event.
| Event | |||||
|---|---|---|---|---|---|
| onended | Yes | 9.0 | Yes | Yes | Yes |
Syntax
In HTML:
<element
onended="myScript">Try it Yourself
In JavaScript:
object.onended=function(){myScript};Try it Yourself
In JavaScript, using the addEventListener() method:
object.addEventListener("ended", myScript);Try it Yourself
Note:Internet Explorer 8 and earlier versions of IE do not supportaddEventListener()the method.
Technical Details
| Does it bubble: | No |
|---|---|
| Can it be canceled: | No |
| Event type: | Event |
| Supported HTML tags: | <audio>, <video> |

More Examples
Example
Execute JavaScript after the video has finished playing:
<video onended="myFunction()">
Try it Yourself »
Event Object
Other Extensions