HTML Audio/Video DOM errorEvents
HTML Audio/Video DOM Reference Manual
Example
An error message pops up when a video loading error occurs:
var vid = document.getElementById("myVideo");
vid.onerror = function() {
alert("Error! Something went wrong");
};
vid.onerror = function() {
alert("Error! Something went wrong");
};
Definition and Usage
The error event is triggered when an error occurs during the loading of audio/video.
Tip:Events affecting multimedia data loading:
Browser Support
The numbers in the table indicate the version number of the first browser that supports the event.
| Events | |||||
|---|---|---|---|---|---|
| error | Yes | 9.0 | Yes | Yes | Yes |
Syntax
In HTML:
<element onerror="myScript">
In JavaScript:
object.onerror=function(){myScript};
In JavaScript, using the addEventListener() method:
object.addEventListener("error", myScript);
Note:Internet Explorer 8 and earlier IE versions do not supportaddEventListener()method.
Technical Details
| Supported HTML tags: | <audio> and <video> |
|---|---|
| Supported JavaScript objects: | Audio, Video |
HTML Audio/Video DOM Reference Manualother extensions