I have 2 pages
page1.html
<html>
<head>
<script src="sorttable.js"></script>
<script type="text/javascript">
function PrintDiv(id) {
var divToPrint = document.getElementById(id);
var popupWin = window.open("page2.html");
// what here?
popupWin.document.getElementById('div2').appendChild(divToPrint);
popupWin.document.getElementById(id + '_t').style.display = "block";
popupWin.document.getElementById(id + '_t').setAttribute("class","sortable");
}
</script>
</head>
<body >
<div id="divToPrint" >
<table class = "sortable" id="divToPrint_t" style="display:none;">
<tr>
<th>Edificio</th>
<th>Tipo</th>
</tr>
<tr>
<td>E1</td>
<td>T1</td>
</tr>
<tr>
<td>A1</td>
<td>Q1</td>
</tr>
</table>
</div>
<div>
<input type="button" value="print" onclick="PrintDiv('divToPrint');" />
</div>
</body>
</html>
page2.html
<html>
<head>
<script src="sorttable.js"> </script>
</head>
<body>
<div id="div2">
</div>
</body>
</html>
I need that, when I press button, open new tab, with page2.html, and with the table in the DIV div2... with display block, and keeping class sortable for sorting.
How can do it?