onabort 事件
定義和用法
onabort 事件會(huì)在圖像加載被中斷時(shí)發(fā)生。
當(dāng)用戶在圖像完成載入之前放棄圖像的裝載(如單擊了 stop 按鈕)時(shí),就會(huì)調(diào)用該句柄。
語法
onabort="SomeJavaScriptCode"
參數(shù) | 描述 |
---|---|
SomeJavaScriptCode | 必需。規(guī)定該事件發(fā)生時(shí)執(zhí)行的 JavaScript。 |
支持該事件的 HTML 標(biāo)簽:
<img>
支持該事件的 JavaScript 對(duì)象:
image
實(shí)例 1
在本例中,如果圖像的加載被中斷,則會(huì)顯示一個(gè)對(duì)話框:
<img src="image_w3default.gif"
onabort="alert('Error: Loading of the image was aborted')"
/>
實(shí)例 2
在本例中,如果圖像的加載中斷,我們將調(diào)用一個(gè)函數(shù):
<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>