Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

copy entire DOM to new window

Tags:

javascript

Hello I have a rendered jsp that does what I want, I need to show it on the second display, how would I copy the entire dom of the current window and create a completely new window? I will later want from the master to further edit that child window and write to it. Any insight greatly appreciated.

like image 718
cp. Avatar asked Feb 13 '11 01:02

cp.


People also ask

How to duplicate a DOM element?

Use the node. cloneNode() method to clone the node. Pass true into the cloneNode() method to create a deep clone of a DOM element.

How to duplicate div in HTML?

Select the target element where div element is copied. Use the append() method to copy the element as its child.

How to clone element HTML?

The cloneNode() method creates a copy of a node, and returns the clone. The cloneNode() method clones all attributes and their values. Set the deep parameter to true if you also want to clone descendants (children).

How to clone a div in JavaScript?

If you want to also copy elements nested inside it, pass in true as an argument. // Get the element var elem = document. querySelector('#elem1'); // Create a copy of it var clone = elem. cloneNode(true);


1 Answers

That would be tricky. You can certainly open a new window and communicate with it but you can't pass DOM objects. You would basically need to convert the generated DOM to a string, pass it across to the new window and then parse it as though it was a document.

Like this: Copy Current Webpage Into a New Window

like image 69
SpliFF Avatar answered Sep 18 '22 14:09

SpliFF