Try the following:
$("div#foo").click ( function() { var copyHTML = $("table.bar").html(); var newWindow = window.open(''); newWindow.document.body.innerHTML = copyHTML; } );
This will work in some cases, and it will be easier than the following approach.
If you get security warnings in your browser, the following approach may be more enjoyable. Add a function to the parent page named getContent, for example:
function getContent() { return $("table.bar").html(); }
... and on document.ready in the child window do the following:
$(document).ready ( function() { var parentContent = window.opener.getContent(); $("body").html(parentContent); } );
source share