tags:

views:

25

answers:

1

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?

A: 

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.

mjhm
So far I have tested, if the image url is incorrect, all browsers fire onerror very quickly. Now I have a script that fails unhandled if both events would be fired. Since both onerror and onabort are called asynchronously, the handling would be quite a problem. If only both calls could not happen... but I am not sure and google gave me no answer.
Jan Turoň
Yeah, I know that dealing with asynchronous behavior can be tricky. I've found the YUI3 AsyncQueue module to be a help -- but even with that it can still be a brain twister.
mjhm