I carefully read the question ‘Official way to ask jQuery wait for all images to load before executing something’, but IE is giving me a hard time.
I want to fade in some images after the background image has load, so thanks for the explanation, all is working well on FF, Safari and Chrome. It doesn’t seem to work on IE though. Tried it on two different computers, with IE version 8 (8.0.7).
Can someone advise me on this one please? My website is http://www.laforcemajeure.nl
This is my code, which is on the bottom of my script.js file:
$(window).load(
function() {
$("#allbirds").fadeIn(2000);
}
);
You’re attaching your
window.onloadfunction inside adocument.readyhandler, instead move it outside.onloadfires once, and if you bind after that happens you’re just out of luck, that seems to be what’s happening in your case.Different browsers have slightly different behavior on the timing of the
readyevent for jQuery, as a fallback it’ll usewindow.onloaditself which means if this happens and you’re binding to an event inside that handler, it’s too late…the event has already fired.Rule of thumb: keep your
$(window).load()handlers outside your$(document).ready()handlers.