Skip to main content

Bug Tracker

Side navigation

#978 closed bug (fixed)

Opened February 19, 2007 05:46PM UTC

Closed March 24, 2007 02:04AM UTC

[PATCH] IE doesn't like domManip in an iframe

Reported by: jeffkretz Owned by:
Priority: minor Milestone: 1.1.3
Component: core Version: 1.1.1
Keywords: domManip Cc:
Blocked by: Blocking:

IE has a security precaution when fiddling with the DOM. When creating a DOM element in one context, it will not let you move it to another context in a different window, even a child iframe.


var iframe = $('iframe')[0];
$(iframe.contentWindow.document.body).append('<div>This is a test</div>');

Throws an exception "invalid argument". Note that this code works fine in FF and Opera, it's just an IE issue. In stepping through the code, the clean method creates the dom elements under the context of the main page document. It seems to me that if the clean method could somehow use the document in the context of the element being manipulated, it would solve this problem.


Attachments (1)
  • msie_html_fix.patch (1.2 KB) - added by vmx March 15, 2007 03:53PM UTC.

    A patch to fix IE problems with append(), html() and wrap() in iframes

Change History (4)

Changed March 15, 2007 03:53PM UTC by vmx comment:1

JK, you are absolutely right. The nodes in clean() need to be created in the context of the iframe document.

I'm not quite sure if the ownerDocument property is crossplattform, but if it is, this patch should work on all browsers (although it only need to work with IE, as the Bug occurs only there).

Changed March 15, 2007 04:18PM UTC by brandon comment:2

summary: IE doesn't like domManip in an iframe[PATCH] IE doesn't like domManip in an iframe

Changed March 16, 2007 05:20PM UTC by jeffkretz comment:3

Thanks, this is terrific. According to Koch at Quirksmode, ownerDocument works on everything except IE 5.

I know that there are already some 5.5 compatibility issues with jQuery, so I don't know if this is really important to solve.


Changed March 24, 2007 02:04AM UTC by john comment:4

resolution: → fixed
status: newclosed

Fixed in SVN rev [1570].