onerror Event Sample

This sample uses the onerror event to handle an error while an object is downloading. Click the Load First Image button to load the invalid image source. When the button is clicked, a specific onerror handler is set on the IMG object, and the value of the ALT attribute is changed accordingly.

In addition to changing the value of the ALT attribute, Dynamic HTML allows authors to use other means to recover from load errors. Click the Load Second Image button to load an invalid image source. When the button is clicked, the error handler adds some alternate HTML to be displayed in place of the image.




[Right-click and choose View Source from the shortcut menu.]

© 2007 Microsoft Corporation. All rights reserved. Terms of use.