Javascript- Onabort Event Handler 


               


Javascript- Onabort Event Handler


Javascript



The Onabort event handler in Javascript is an event handler that executes when a viewer aborts (stops) the loading of an image element.

If the user presses the Stop button of a browser or attempts to redirect to a new page before the loading of the image has occurred, the onabort event handler will be triggered.

The onabort event handler is useful in situations where we want a user to be aware that s/he is attempting to leave the page without having seen the fully loaded image that the page contains.

Just like any other event handler in Javascript, we can program the onabort event handler to do anything we want it to do. In the example below, we will program an image element so that the onabort event handler will create an alert pop-up stating, "The image hasn't loaded completely yet. You haven't seen the full image."

The code to program an image tag that will call this alert pop-up box when a user attempts to abort the loading of it is:

<img width="444" height="332" alt="Pond"
src="/images/Pond.JPG"
onabort="window.alert('The image hasn't loaded completely yet. You haven't seen the full image.');">

If the loading of the image is aborted, an alert pop-box will be invoked.


Related Resources

Javascript- Onload Event Handler

Javascript- Onunload Event Handler

Javascript- Onfocus Event Handler

Javascript- Onblur Event Handler

Javascript- Onclick Event Handler

Javascript- Onchange Event Handler

Javascript- Onkeydown Event Handler

Javascript- Onkeyup Event Handler

Javascript- Onmouseover Event Handler

Javascript- Onmousedown Event Handler

Javascript- Onmouseup Event Handler

Javascript- Onmouseout Event Handler

Javascript- Onreset Event Handler

Javascript- Oncopy Event Handler



HTML Comment Box is loading comments...