Mega Code Archive

 
Categories / JavaScript Tutorial / HTML Tags
 

Add onerror handler to image element within document element array (IE)

< html> <head>     <title>Image Error Test</title>     <script type="text/javascript">         function handleLoad() {             document.images[0].onerror = function () {                 alert("An error occurred loading the image.");             };             document.images[0].src = "doesNotExist.gif";         }     </script> </head> <body onload="handleLoad()">     <P>The image below attempts to load a file that doesn't exist.</p>     <img/> </body> </html>