Can't Appendchild To A Node Created From Another Frame
I have a page with an iframe and would like to extract a DOM node from the child frame and put it on the parent page. This works in Firefox (3.5), but not in Internet Explorer (7).
Solution 1:
Your problem is that you are not adopting the nodes into the fragment that are created in the current document. Use either the following:
fragment.appendChild(fragment.ownerDocument.createElement("div"));
or
fragment.appendChild(fragment.ownerDocument.adoptNode(document.createElement("div"));
Solution 2:
I'm just hazarding a guess here, but you could try creating the div using
var div = frames[0].document.createElement("div")
instead of
var div = document.createElement("div")
Using the main document's createElement() method may be why IE is having a problem.
Solution 3:
I think I found the answer here: http://www.alistapart.com/articles/crossbrowserscripting/
Importing documents from two different ownerDocument properties ... requires the use of the DOM Level 2 method importNode(), since in these cases the DOM will not allow a simple document.appendChild().
Post a Comment for "Can't Appendchild To A Node Created From Another Frame"