Image onerror Event
Image Object
Definition and Usage
The onerror event is triggered when an error occurs during the loading of a document or image.
Syntax
onerror="
JavaScriptCode
"
| Parameters | Description |
|---|---|
| JavaScriptCode | Required. Specifies the JavaScript to be executed when the event occurs. |
Browser support





All major browsers support the onerror event
Example
Example
In this example, if an error occurs while loading the image, a dialog box is displayed:
Try it »
Image Object