Home  >  Article  >  Web Front-end  >  Onabort is an event that occurs when image loading is interrupted in HTML.

Onabort is an event that occurs when image loading is interrupted in HTML.

黄舟
黄舟Original
2017-11-07 10:51:442064browse

Definition and Usage

onabort Event Occurs when image loading is interrupted.

This handler is called when the user gives up loading the image before it has finished loading (such as clicking the stop button).

Syntax

onabort="SomeJavaScriptCode"
Parameters Description
SomeJavaScriptCode Required. Specifies the JavaScript to be executed when this event occurs.

HTML tag that supports this event:

<img>

JavaScript that supports this event Object:

image

Instance 1

In this example, if the loading of the image is interrupted, a dialog box will be displayed:

<img src="image_w3default.gif"onabort="alert(&#39;Error: Loading of the image was aborted&#39;)" />

Example 2

In this example, if the loading of the image Interrupt, we will call a function:

<html>
<head>
<script type="text/javascript">
function abortImage()
{
alert(&#39;Error: Loading of the image was aborted&#39;)
}
</script>
</head>

<body>
<img src="image_w3default.gif" onabort="abortImage()" />
</body>

</html>


The above is the detailed content of Onabort is an event that occurs when image loading is interrupted in HTML.. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn