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

I understand that Image.onaborteither Image.onerrorworks if the image was not loaded successfully. But when is they fired? Can they work as in some circumstances?

+3
source share
1 answer

Cancellation usually comes from user action. For example, if image A has not finished loading, but the user presses a JavaScript button that switches “src” to image B. Then image A will receive an “abort” event. I think that if you press the stop button, it will also trigger an interrupt event. Errors come from a bad file or something similar that prevents the file from loading.

I would suggest that it is possible for both of them to shoot, but I also think that it would be rare.

+1
source

Source: https://habr.com/ru/post/1771868/


All Articles