onabort=eventHandler() - Javascript DOM Event

Javascript examples for DOM Event:Element Event Attribute

Description

The onabort event occurs when the user aborts the loading of an <img> or <input type="image"> element.

Summary

Bubbles Yes
Cancelable No
Supported HTML tags: <img> and <input type="image">

Execute a JavaScript if loading of an image is aborted:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<image id = 'demo' src='http://java2s.com/resources/a.png' onabort="myFunction()"/>

<script>
document.getElementById("demo").onabort = function() {myFunction()};

function myFunction() {//from   ww  w .ja v  a  2s.co  m
    console.log("abort");
}
</script>

</body>
</html>

Related Tutorials