Bug Tracker

Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#1251 closed bug (worksforme)

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:

Description

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):

http://mg.to/test/jquery-defer.html

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: "0.style 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)

jquery-defer.html (692 bytes) - added by geary 13 years ago.

Download all attachments as: .zip

Change History (6)

Changed 13 years ago by geary

Attachment: jquery-defer.html added

comment:1 Changed 13 years ago by john

Milestone: 1.1.31.1.4
Version: 1.1.21.1.3

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

comment:2 Changed 13 years ago by dimka

this is still an issue in 1.1.3.1.

comment:3 Changed 13 years ago by john

Owner: set to john

comment:4 Changed 13 years ago by john

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: http://dev.jquery.com/~john/ticket/1251/

comment:5 Changed 13 years ago by dimka

works after ticket #1320

Note: See TracTickets for help on using tickets.