Opened 16 years ago
Closed 16 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)
Change History (5)
Changed 16 years ago by
Attachment: | msie_html_fix.patch added |
---|
comment:1 Changed 16 years ago by
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 16 years ago by
Summary: | IE doesn't like domManip in an iframe → [PATCH] IE doesn't like domManip in an iframe |
---|
comment:3 Changed 16 years ago by
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
A patch to fix IE problems with append(), html() and wrap() in iframes