JavaScript Events: OnError, OnFocus and More - OnError
(Page 2 of 6 )
The OnError event occurs when there is an error while loading a document or an image.
Here it is in code:
<html>
<body>
<img src="messedupimage.gif"
onerror="alert('You are so fat we cannot upload your image. Please try again when you lose 4000 pounds.')">
</body>
</html>
As you can see, when the page loads and tries to upload the image named "messedupimage.gif" an error message pops up, telling the user they are too fat and to try again when they loose 4,000 pounds. The triggering even for this is the missing image. Since there is no image file with that name in the directory, it causes the error message to pop up.
Supporting HTML tags: <img>, <object>, <style>
Supporting Javascript Objects: window, image
Next: OnFocus >>
More JavaScript Articles
More By James Payne