Other Image Properties

本文介绍了<img>标签在图片加载过程中的关键属性:onload、onerror、onabort及complete。这些属性帮助开发者更好地控制和响应图片加载的各种状态。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

来自Javascript Definitive Guide,了解<img>标签的属性

[quote]In addition to the onload event handler demonstrated in Example 22-4, the Image object supports two others. The onerror event handler is invoked when an error occurs during image loading, such as when the specified URL refers to corrupt image data. The onabort handler is invoked if the user cancels the image load (for example, by clicking the Stop button in the browser) before it has finished. For any image, one (and only one) of these handlers is called.

Each Image object also has a complete property. This property is false while the image is loading; it is changed to true once the image has loaded or once the browser has stopped trying to load it. In other words, the complete property becomes true after one of the three possible event handlers is invoked.[/quote]

除了onload,onerror,onabort这些图片加载周期中的句柄属性,还有一个complete属性,当加载完成会或者取消加载时,浏览器将设置成ture(也就是之前的那三个事件之一被触发),否则为false

还有些属性就是<img>标签自带的一些属性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值