Web/API/HTMLMediaElement/error

From Get docs


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 StandardThe definition of 'HTMLMediaElement.error' in that specification. Living Standard  
HTML5The definition of 'HTMLMediaElement.error' in that specification. Recommendation  

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
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