问题描述:

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.

相关阅读:
Top