IE 6 & 7 window.onload

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

IE 6 & 7 window.onload

Post by JellyFish »

Okay, does IE execute window.onload event before it loads? Cause in firefox my script is working fine but in IE it does not. I think I remember reading that IE's onload event fires when it's loading, not after (like firefox).

Details are appreciated.

Thanks for reading my post.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

I don't think so. Are you sure onload's the culprit? (I, personally, always get caught by stray commas in my object definitions. Firefox handles them gracefully but IE barfs).
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

If I recall correctly, the onload event fires after ALL ELEMENTS on the page have loaded, including external scripts, images, etc... There is a different event handler out on the net that will let you attach your function to it, and it will get fired after the DOM is ready to manipulate.

I can't remember where I saw the code, but I'm using jQuery right now, and it's as simple as:

Code: Select all

$(document).ready(function(){/*take over the world here*/});
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

nickvd, you're right, but that distinction would only make the IE script run slower, not stop it working entirely.
Post Reply