Skip to main content

Bug Tracker

Side navigation

#1251 closed bug (worksforme)

Opened May 29, 2007 07:22AM UTC

Closed July 20, 2007 04:53PM UTC

Last modified July 20, 2007 08:43PM UTC

Setting .innerHTML while document loading breaks $(document).ready() in IE

Reported by: geary Owned by: john
Priority: major Milestone: 1.1.4
Component: core Version: 1.1.3
Keywords: Cc:
Blocked by: Blocking:

If JavaScript code sets the innerHTML of any element while the document is loading, $(document).ready() fires prematurely in IE. I believe the .innerHTML assignment causes IE to ignore the "defer" attribute in the special script tag used in $(document).ready().

To test, load this page (HTML also attached to the ticket):

If you don't get an error, reload the page several times and the error will occur soon enough. In a larger test case, the error happens every time.

In Firefox, the page loads without error, and the text "One!" is set to red by jQuery code running under $(document).ready().

In IE7, the page sometimes loads OK, but sometimes hits an error on line 9: " is not null or not an object".

Of course, JavaScript code should not be setting .innerHTML while the page loads. However, many sites have code loaded from advertising networks that does bad things like this, and it is not always possible to prevent that code from running.

Attachments (1)
Change History (5)

Changed July 15, 2007 03:31PM UTC by john comment:1


@geary: Is this still an issue? We resolved some IE loading issues in

Changed July 19, 2007 04:51PM UTC by dimka comment:2

this is still an issue in

Changed July 20, 2007 03:13PM UTC by john comment:3

owner: → john

Changed July 20, 2007 04:53PM UTC by john comment:4

resolution: → worksforme
status: newclosed

I, honestly, can't get this to duplicate, so I think this has been resolved. Please let me know if that is not the case.

My test:

Changed July 20, 2007 08:43PM UTC by dimka comment:5

works after ticket #1320