Error events (Definition)

A class of events that are triggered by errors.

HTML syntax:<IMG onError="...">

There is an onError event defined as part of the set of events supported by JavaScript. However, as of JavaScript version 1.2, the onError event is actually only supported by Image objects when defined in HTML tag attributes. You can add an error handler to a window object with the onerror property.

The <IMG onError="..."> tag element allows an error during image loading to be handled gracefully.

Attaching an error handler to a window with the window.onerror property allows JavaScript errors to be intercepted.

Error events have a slightly different parameter passing API so although they are events, they are slightly different to the rest of the event model.

See also:Error handler, Event handler, Event model, onError, Window.onerror