The basic problem here is that IE has security restrictions about moving
elements between frames.  You can't create an element in one frame and add
it to another.

 

For example, this code will always fail in IE:

 

var doc = $('#testframe')[0].contentWindow.document;

$('<span>test</span>').appendTo(doc.body);

 

Because it is creating the element in the default context, which is the
parent document, and then adding it to the iframe's document, which is in a
completely different context.

 

However, this came up in 1.1.2 and a fix was added to the "clean" method
(the method that creates new html elements) which will use the context of
the supplied element to create the new element.  This was released in 1.1.3.
So the following code WILL work in IE:

 

var doc = $('#testframe')[0].contentWindow.document;

$(doc.body).append('<span>test</span>');

 

Because it is using the iframe document as the context to create the new
element in, so no security violation.

 

JK

 

  _____  

From: jquery-en@googlegroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Matt Stith
Sent: Sunday, August 12, 2007 9:21 PM
To: jquery-en@googlegroups.com
Subject: [jQuery] Re: how to use $(html) to create element in another frame?

 

Hmm.. try:

$("<div>bbbb</div>").appendTo($(document.blahblah));

Reply via email to