Cloning nodes from an iframe

Atom RSS

This site heavily relies on bug reports created by its readers. Anyone can report a bug and be published.

Main navigation:




Search reports by browser:

It is impossible to clone nodes in an iframe and append these clones to a node in the main page. Copying innerHTML works fine, though.

Test page. Workaround is not included.
Reported by Jaap Roes.

(Orphaned), Explorer 5-6 Windows, Explorer Mac, Opera | Reported on 21 November 2004.

Comments

(Add your own)

Posted by Sebastian Redl on 24 November 2004

1

This is not really a bug. cloneNode does not change the owning document, which is, even for the clones, the iframe's document. It is therefore illegal and should throw a DOMException with this error code:
WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that created this node.

http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247

Seen this way, it is Mozilla who has the bug by being too lenient.

However, IE has a real bug in that it doesn't support Document.importNode, which would be the proper way to do this.

Posted by Mark Wubben on 24 November 2004

2

I wrote a workaround for this some time ago:
http://neo.dzygn.com/archive/2004/02/the-ie-factor

Posted by Alex on 16 February 2005

3

The cloneNode method will not work on an IFRAME directly. You must call it through the all collection.

Have you tried using: var data = document.all.foo.cloneNode();

Please see the following link for more information.

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/methods/clonenode.asp

Post a comment

Commenting guidelines:

  1. When quoting specs, articles or your own research, please include a URL of the document.
  2. Test your stuff. When reporting browser behaviour, make sure that your report is correct.

Yes