I need to be able to copy the current webpage into a new popup window for a print preview. There is a grid on the page with children, so if they expand one of the rows to see the child rows, I need to show this in the new window.
Is this possible?
I currently have the popup window open up the same page, but all none of the rows are expanded.
Perhaps this does the trick (in IE and Firefox, not in Opera. Don't know about WebKit):
var yourDOCTYPE = "<!DOCTYPE html..."; // your doctype declaration
var printPreview = window.open('about:blank', 'print_preview');
var printDocument = printPreview.document;
printDocument.open();
printDocument.write(yourDOCTYPE+
"<html>"+
document.documentElement.innerHTML+
"</html>");
printDocument.close();
(Note the difference between window.open()
and document.open()
!)
However, you will lose all custom DOM thingies, like event handlers and so on. Nonetheless, it might work if you just want to copy 'n paste your HTML.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With