Slowing Down mywindow.print()
Posted
by TraderY
on Stack Overflow
See other posts from Stack Overflow
or by TraderY
Published on 2010-05-11T19:18:13Z
Indexed on
2010/05/11
19:24 UTC
Read the original article
Hit count: 182
JavaScript
I'm using this nice printing script:
<script type="text/javascript">
function PrintElem(elem)
{
Popup($(elem).text());
}
function Popup(data)
{
var mywindow = window.open('', 'my div', 'height=400,width=600');
mywindow.document.write('<html><head><title>my div</title>');
/*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
mywindow.document.write('</head><body >');
mywindow.document.write(data);
mywindow.document.write('</body></html>');
mywindow.document.close();
mywindow.print();
return true;
}
</script>
</head>
<body>
It works fine except for two things:
mywindow.print()
is triggered before the page has completely loaded so you can't see the material in the window to be printed (if you select "Print" it prints correctly though).- The print dialog box opens on top of the window blocking the contents (presuming #1 is an easy fix). How can it positioned?
Thanks - TY
© Stack Overflow or respective owner