当前位置: 动力学知识库 > 问答 > 编程问答 >

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

问题描述:

I understand that Image.onabort or Image.onerror 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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: