开发者

What is the difference between Image.onabort and Image.onerror?

开发者 https://www.devze.com 2023-01-22 13:12 出处:网络
I understand that Image.onabort or Image.onerror开发者_JAVA百科 fires if image was not loaded successfully. But when is fired which? Can they fire both in some circumstances?Abort generally comes from

I understand that Image.onabort or Image.onerror开发者_JAVA百科 fires if image was not loaded successfully. But when is fired which? Can they fire both in some circumstances?


Abort generally comes from a user action. For example if image A hasn't finished loading, but the user hits a JavaScript button that switches the "src" to image B. Then image A would get an "abort" event. I think if you hit the stop button it would trigger the "abort" event as well. Error events would come from a bad file or something like that that prevents the file from loading.

I would guess that it's possible for them both to fire, but I would also guess that it would be rare.

0

精彩评论

暂无评论...
验证码 换一张
取 消