onemptied Event
Example
Execute a JavaScript when the loading of a video is aborted:
<video onabort="myFunction()">
Definition and Usage
The onemptied event occurs when the an audio or video is empty.
The onemptied is not sent when a media has finished loading.
The onemptied is only sent if the load() method is called,
and the media has already been loaded.
Audio and Video Events
While loading a media, 7 events occur in the following order:
| Event | Occurs When | Bubbles |
|---|---|---|
| onloadstart | The loading of a media starts | No |
| ondurationchange | The duration of a media is changed | No |
| onloadedmetadata | The meta data for a media has been loaded | No |
| onloadeddata | A media frame is loaded | No |
| onprogress | The browser is loading a media | No |
| oncanplay | An element's scrollbar is being scrolled | No |
| oncanplaythrough | The browser estimates it can play a media | No |
Other events that can occur in the media loading process:
| Event | Occurs When | Bubbles |
|---|---|---|
| onabort | The loading of a media is aborted | No |
| onemptied | A media is empty (already loaded) | No |
| onerror | An error occurs while loading a media | No |
| onstalled | Media data is not available | No |
| onsuspend | The browser is not getting the media data | No |
See Also:
Syntax
In HTML:
<element onabort="myScript">In JavaScript:
object.onabort = function(){myScript};
In JavaScript, using the addEventListener() method:
object.addEventListener("abort", myScript);Technical Details
| Bubbles: | No |
|---|---|
| Cancelable: | No |
| Event type: | UiEvent if generated from a user interface, Event otherwise. |
| Supported HTML tags: | <audio> and <video> |
| DOM Version: | Level 3 Events |
Browser Support
onabort is a DOM Level 3 (2004) feature.
It is fully supported in all browsers:
| Chrome | Edge | Firefox | Safari | Opera | IE |
| Yes | Yes | Yes | Yes | Yes | 9-11 |