Appending Same Node In Different Windows
I want to append an object, that was created in a parent window to a child window: div = document.createElement( 'div' ); document.body.appendChild( div ); // Here come div's atts;
Solution 1:
Editing since I misread the question:
newelement = element.cloneNode(true); // true to clone children too
Still there is no html or body in the new window that it can be appended to. At least not in chrome.
Try this instead:
<html><body><script>
div = document.createElement( "div" );
// add some text to know if it's really there
div.innerText = 'text of the div';
document.body.appendChild( div );
// Here come div's atts;
render = window.open().document;
// create the body of the new document
render.write('<html><body></body></html>');
// now you can append the div
render.body.appendChild( div );
alert(render.body.innerHTML);
</script></body></html>
Solution 2:
Have you tried creating a copy of that div and then appending that to the child instead of the original div?
Edit: Okay, then yeah, that would be the cloneNode function.
clone = div.cloneNode(true);
render = window.open().document;
render.body.appendChild(clone);
Post a Comment for "Appending Same Node In Different Windows"