Jump to content

IE8 attachEvent order


Lucy

Recommended Posts

I'm using several Javascript files with (for IE8 and below) window.attachEvent("onload", function). In Firefox, using addEventListener, everything loads as I'd expect. The load function for each file happens in the same order as the files are listed. However, in IE8 the order is wrong. The files are definitely loading in the correct order, but the onload functions don't. Which is a slight problem, as there are a couple of things that depend on the other files. Does anyone have any experience with this?

Link to comment
Share on other sites

IE8 and below...really, why? even they admit these are the worst effort of browser ever which ruin their reputation and brought them now to less than 10% statistically browser usage, they are now trying to rebrand from IE name to Spartan (IE in pink spandex).

Link to comment
Share on other sites

IE8 and below...really, why? even they admit these are the worst effort of browser ever which ruin their reputation and brought them now to less than 10% statistically browser usage, they are now trying to rebrand from IE name to Spartan (IE in pink spandex).

I know, I know... but still, 10% isn't a tiny number. I'm trying to get freelance work in web development, and want to be prepared for any clients who ask me to support earlier versions of IE. Life would be so very much easier if it didn't seem necessary...

 

What exactly are you doing? Do you have functions that load external files and then do something once it finishes loading?

I have a few files with a function added to the onload event. The first file detects certain elements that only show up on mobile screen sizes and assigns them to variables/uses them, etc. The other files, which load afterwards, were to use some of these to avoid repeatedly assigning variables... but in IE8, the first files' onload function doesn't actually fire until after that of the other files. It's not that important, I suppose, it just seems a bit messy having to do it this way.

Edited by Lucy
Link to comment
Share on other sites

With a lot of issues with IE it's almost not even worth it to try and figure out what it's doing and why, I typically just go straight for a workaround. One possibility would be to have the other functions check if the first one has executed yet (I assume it would set some variables or things that the other ones could detect), and if it hasn't executed yet then use setTimeout to schedule the function to run again after a few milliseconds.

Link to comment
Share on other sites

It depends on where you're getting the numbers from, I wouldn't use W3Schools as a reliable source. They even have a disclaimer at the bottom of the page:

W3Schools is a website for people with an interest for web technologies. These people are more interested in using alternative browsers than the average user. The average user tends to use the browser that comes preinstalled with their computer, and do not seek out other browser alternatives.

 

There are still many people who use IE8. I wouldn't support IE7 or under, though.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...