The HTMLMediaElement.error
is the MediaError
object for the most recent error, or null
if there has not been an error. When an error
event is received by the element, you can determine details about what happened by examining this object.
Syntax
var myError = HTMLMediaElement.error;
Value
A MediaError
object describing the most recent error to occur on the media element or null
if no errors have occurred.
Example
This example establishes a video element and adds an error handler to it; the error handler simply logs the details to console.
var videoElement = document.createElement('video'); videoElement.onerror = function() { console.log("Error " + videoElement.error.code + "; details: " + videoElement.error.message); } videoElement.src = "https://example.com/bogusvideo.mp4";
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'HTMLMediaElement.error' in that specification. |
Living Standard | |
HTML5 The definition of 'HTMLMediaElement.error' in that specification. |
Recommendation |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
error | Chrome Full support 43 | Edge Full support 12 | Firefox Full support 3.5 | IE Full support 9 | Opera Full support Yes | Safari Full support 6 | WebView Android Full support 43 | Chrome Android Full support 43 | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support 4.0 |
Legend
- Full support
- Full support
See also
- The interface defining it,
HTMLMediaElement
. <audio>
and<video>