Bug Tracker

Opened 13 years ago

Closed 13 years ago

#978 closed bug (fixed)

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

Description

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.

Example:

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.

JK

Attachments (1)

msie_html_fix.patch (1.2 KB) - added by vmx 13 years ago.
A patch to fix IE problems with append(), html() and wrap() in iframes

Download all attachments as: .zip

Change History (5)

Changed 13 years ago by vmx

Attachment: msie_html_fix.patch added

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

comment:1 Changed 13 years ago by vmx

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

comment:2 Changed 13 years ago by brandon

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

comment:3 Changed 13 years ago by jeffkretz

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

http://www.quirksmode.org/dom/w3c_core.html#t119

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.

JK

comment:4 Changed 13 years ago by john

Resolution: fixed
Status: newclosed

Fixed in SVN rev [1570].

Note: See TracTickets for help on using tickets.