Bug Tracker

Ticket #978 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

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

Reported by: jeffkretz Assigned to: anonymous
Type: bug Priority: minor
Milestone: 1.1.3 Component: core
Version: 1.1.1 Keywords: domManip
Cc: Needs:

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

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

Change History

Changed 2 years ago by vmx

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

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

Changed 2 years ago by brandon

  • summary changed from IE doesn't like domManip in an iframe to [PATCH] IE doesn't like domManip in an iframe

Changed 2 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

Changed 2 years ago by john

  • status changed from new to closed
  • resolution set to fixed

Fixed in SVN rev [1570].

Note: See TracTickets for help on using tickets.