onerror | NN 3 IE 4 DOM 2
| Bubbles: No; Cancelable: Yes
Fires after one of a variety of errors occurs, depending on the element or object to which the event handler is assigned. For elements that load external content, such as the img element, errors during loading (such as an invalid URL) fire the onerror event on the img element. When assigned to the window object (including direct assignment in the <body> tag), overall runtime script errors (not compile-time syntax errors) also fire the onerror event. A technique that some scripters used in earlier browsers that plastered script error messages inside intrusive alert dialog boxes was to trap all runtime errors in the following manner:
This isn't good for debugging because you need to find errors during development. See the Error object in Chapter 9 for more details on processing errors from this event handler. Eventually, there will enough browsers deployed that use more modern exception handling.
Typical Targets
Elements that load external content, plus the window object.