JQuery bind ("load")
var imgLoader = $("<img />"); $(imgLoader).attr("src", "http://localhost/malevil/Content/Images/img_adrenalin.jpg"); $(imgLoader).unbind('load'); $(imgLoader).bind('load', function () { alert("event fired"); }); But this only works in chrome, where is the problem? In IE, Firefox and Opera boot events never fired.
You need to bind the load event before setting the src property.
As a side note, there are known issues with the upload event on images that you need to know about:
And, quoting the jQuery manual on load() :
- It does not work consistently, reliable cross browser
- This is not correct to run in WebKit if the src image is set to the same src as before
- This is wrong DOM tree
- You can cease fire for images that already live in the browser cache