Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#9605 closed bug (invalid)

Trouble with IE6 and the $('html') function with iframes

Reported by: [email protected] Owned by:
Priority: low Milestone: 1.next
Component: manipulation Version: 1.6.1
Keywords: neededdocs Cc:
Blocked by: Blocking:


I am trying to create html using the $() function and then insert this into the body of an iframe. It works fine on firefox and chrome, but messes up in IE6 (naturally). Here's what the code looks like:


IE6 gives the error "invalid argument" whenever the div is surrounded by $(). If I remove the $(), it works fine. There's definitely a workaround for this, but it seems like something that ought to work but doesn't.

Change History (5)

comment:1 Changed 12 years ago by timmywil

Component: unfiledmanipulation
Priority: undecidedlow

The docs do not show a jQuery object as a valid argument for html. http://api.jquery.com/html/ However, maybe they should?

comment:2 Changed 12 years ago by timmywil

Keywords: needsreview added

comment:3 Changed 12 years ago by addyosmani

Keywords: needsdocs added; needsreview removed
Resolution: invalid
Status: newclosed

Thanks for submitting a ticket to the jQuery project. I've just tested your ticket out here: http://jsfiddle.net/wLxne/1/ across IE6, 7, 8 and 9 and the main problem with IE appears to be permission/security issues when attempting to modify the contents of the iframe most likely due to cross-site scripting. This is consistant with the errors experienced when attempting to modify the contents of the iframe body (in the same browsers) where the parameters passed to .html() are plain-text or inline HTML as a string.

As per the jsfiddle, .html() does in-fact support jQuery objects so I'll add a needsdocs tag to ensure this is addressed.

comment:4 Changed 12 years ago by dmethvin

IE has significant restrictions in moving DOM nodes from one document to another document (iframe). You can inject new content into the iframe using .innerHTML though. Because of the limits of older IE this isn't something jQuery can support across browsers. Here is some more painful detail:


comment:5 Changed 12 years ago by addyosmani

Keywords: neededdocs added; needsdocs removed

From Dave, Karl and I's discussions regarding this particular ticket (and a correction to my earlier response):

The reason the OP had the problem is that $("html") creates the elements in the current document, and then they were trying to tack them onto a different document in an iframe. IE doesn't allow that.

So the take on this is that there is nothing we need to do, unless we want to document that all content-changing operations (.append, .appendTo, etc.) don't work in IE when you try to put the content in a different document. We however think it's too much of an edge case to clutter the docs everywhere.

Note: See TracTickets for help on using tickets.