--- title: HTMLMediaElement.onerror slug: Web/API/HTMLMediaElement/onerror translation_of: Web/API/HTMLMediaElement/onerror ---
The onerror property of the {{domxref("HTMLMediaElement")}} interface is the {{event("Event_handlers", "event handler")}} for processing {{event("error")}} events.
The error event fires when some form of error occurs while attempting to load or perform the media.
HTMLMediaElement.onerror = EventListener;
A {{jsxref("function")}} which serves as the event handler for the {{event("error")}} event. When an error occurs, the specified function will be called. If null, no error handler is in effect.
| Specification | Status | Comment |
|---|---|---|
| {{SpecName('HTML WHATWG','webappapis.html#handler-onerror','onerror')}} | {{Spec2('HTML WHATWG')}} |
{{Compat("api.HTMLMediaElement.onerror")}}