Skip to main content

Bug Tracker

Side navigation

#9605 closed bug (invalid)

Opened June 16, 2011 05:31PM UTC

Closed July 12, 2011 04:29PM UTC

Last modified July 26, 2011 06:50AM UTC

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

Reported by: Owned by:
Priority: low Milestone:
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.

Attachments (0)
Change History (5)

Changed June 17, 2011 01:38PM UTC by timmywil comment:1

component: unfiledmanipulation
priority: undecidedlow

The docs do not show a jQuery object as a valid argument for html.

However, maybe they should?

Changed June 17, 2011 01:39PM UTC by timmywil comment:2

keywords: → needsreview

Changed July 12, 2011 04:29PM UTC by addyosmani comment:3

keywords: needsreviewneedsdocs
resolution: → invalid
status: newclosed

Thanks for submitting a ticket to the jQuery project. I've just tested your ticket out here: 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.

Changed July 25, 2011 01:08PM UTC by dmethvin comment:4

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:

Changed July 26, 2011 06:50AM UTC by addyosmani comment:5

keywords: needsdocsneededdocs

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.