onError (Event handler)

Triggered if an error occurs when loading an image.


JavaScript - 1.1
JScript - 3.0
Internet Explorer - 4.0
Netscape - 3.0
Opera browser - 3.0
Property/method value type:Boolean primitive
JavaScript syntax:-myObject.onerror = aHandler
HTML syntax:<HTMLTag onError="..."> <IMG onError="...">
Argument list:aHandlerA reference to a function object to handle the event.
Supported by objects:IMG, LINK, OBJECT, SCRIPT, STYLE

There is an onError event defined as part of the set of events supported by JavaScript. However, 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 attribute 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 from the rest of the event model.

The API for the function that is associated with this event should take three parameters.


See also:Error events, Event, Event handler, Event model, Event names, Event object, Event.returnValue, Handler, onAbort, onErrorUpdate, onLoad, Semantic event, Window.onerror


Wrox Instant JavaScript - page - 55