This article describes the usage of the event object onabort event in the DOM of html. Share it for your reference. The specific analysis is as follows:
The onabort event occurs when the image loading is interrupted.
This handle is called when the user abandons the loading of the image before it completes loading (such as clicking the stop button).
grammar:
Copy the code as follows:onabort="SomeJavaScriptCode"
SomeJavaScriptCode is required. Specifies the JavaScript executed when the event occurs.
HTML tags that support this event:
<img>
JavaScript objects that support this event:
image
In this example, if the image loading is interrupted, a dialog box is displayed:
Copy the code as follows:<img src="image_w3default.gif" onabort="alert('Error: Loading of the image was aborted')" />
Example: If the image is loaded interrupted, call a function:
Copy the code as follows: <html>
<head>
<script type="text/javascript">
function abortImage()
{
alert('Error: Loading of the image was aborted')
}
</script>
</head>
<body>
<img src="image_w3default.gif" onabort="abortImage()" />
</body>
</html>
I hope this article will be helpful to everyone's JavaScript programming.