Does the <img> tag have an "onsuccess" attribute? Like "onerror".
I am loading an image. I bind an event with JQuery, which changes image onerror.
i want to show an alert "ONERROR Image loaded successfuly" if onerror image successfully loaded. Otherwise it will show alert "ONERROR image not found".
EDIT:
onload shows alert after loading image. but didn’t tells us that "your real image is loaded" or "browser's default error image is loaded". check here…
http://jsfiddle.net/extremerose71/cHuu6/6/
If you wrote something like:
And also wrote:
(as in
jsfiddleonLoadis corresponded to$(window).load) , you will never get anyalert, because$(window).loadwill be called after all resources is already loaded.But if you would remove
srcfromimg:And then add this
line after the
loadanderrorlisteners , you will see analert.So the main problem was , that you were adding listeners after the image has already loaded or failed to load.