Bug Tracker

Opened 4 years ago

Closed 4 years ago

Last modified 3 years ago

#12018 closed bug (fixed)

$(document).ready() fires too early in IE8

Reported by: torstein@… Owned by: mikesherov
Priority: blocker Milestone: 1.8
Component: core Version: 1.8b1
Keywords: Cc: mikesherov
Blocked by: Blocking:


Demo: http://jsfiddle.net/highcharts/SHD92/

  1. Open the URL in a modern browser like Chrome with the console open. Observe that the linked JavaScript file loads first and prints a message to the console. Then the document ready event fires and logs a message. At this time, $('#container').length is 1.
  1. Open the same URL in IE8. Now the document.ready event fires before the script is loaded, and the container div is not recognized.
  1. In IE8, run the same page with jQuery 1.7.2. Everything works as expected.

Change History (12)

comment:1 Changed 4 years ago by dmethvin

  • Cc mikesherov added
  • Component changed from unfiled to core
  • Milestone changed from None to 1.8
  • Priority changed from undecided to blocker
  • Status changed from new to open

It works in IE8 when run outside the jsFiddle iframe:


In 1.8 we were trying to fire ready when readyState==="interactive" and it doesn't look like we can if jQuery itself is in an iframe:

http://jsfiddle.net/SHD92/3/ http://jsfiddle.net/SHD92/3/show/

Thanks for the report!

comment:2 Changed 4 years ago by anonymous

You're welcome! We had a similar problem in Highcharts with the readyState in IE8. We worked around it by checking if window == window.top (triple equals don't work in this case).

comment:3 Changed 4 years ago by mikesherov

  • Owner set to mikesherov
  • Status changed from open to assigned

Wow, look at that. I'll see there's a workaround. If not, I'll most likely revert. :-\

comment:4 Changed 4 years ago by mikesherov

All is not lost: it seems as if this is only a problem when a script is included before the rest of the content. Also, the doScroll hack still works, I just need to add it to the interactive check for oldIE. Fix coming shortly. Thanks again torstein@… for catching this bug.

comment:5 Changed 4 years ago by Mike Sherov

  • Resolution set to fixed
  • Status changed from assigned to closed

Fix #12018, readyState "interactive" in oldIE lies! Closes gh-848.

Changeset: f5fd41252e3ae48a655c5da4a0b2910bb897b6ed

comment:6 Changed 3 years ago by AndyWNY

This is still happening for us in 1.8.

I do not have a good test case for you right now unfortuantely as I am not 100% yet why it happens only on certain pages... but definitely only happening in 1.8.

comment:7 Changed 3 years ago by AnyWNY

Sorry that was in IE 9.

comment:8 Changed 3 years ago by dmethvin

@AndyWNY, yes it will happen in 1.8.0 since we never go back to change code in a release we've already made and keep the same version number. That would be really confusing! The problem should be fixed in 1.8.1 which should be out in a few days. You can check your code against our work-in-progress version, http://code.jquery.com/jquery-git.js .

comment:9 Changed 3 years ago by kevingrigsby@…

This is not working in IE 9 - I go to the above link (http://jsfiddle.net/highcharts/SHD92) and it returns:

onDomReady0 Then --- running highcharts.src.js from GitHub

It seems that in my code if I put the <script> tag that contains the "ready" function at the BOTTOM of my html page, it works.

It worked fine with jQuery 1.7.1 no matter where the <script> tags were. There are only two small images (that have always been there) and to me, the ready is called when the DOM is ready. Seems like 1.8.0 this is not 100% the case. If only in IE.

comment:10 Changed 3 years ago by dmethvin

@kevingrigsby, you're using the 1.8b1, not even 1.8.0 and certainly not the jquery-git.js that has been fixed. Please, please, please just look one post above.

comment:11 Changed 3 years ago by anonymous

I have the same issue! please release 1.8.1

comment:12 Changed 3 years ago by anonymous

@dmethvin @mikesherov jQuery 1.8 - I have the same problem, IE9 $(document).ready() fires too early.

works fine on jQuery 1.7.2

Please release 1.8.1

Note: See TracTickets for help on using tickets.