I'm currently utilizing a fantastic printing script that I found:
<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>
Although this script works well, there are two issues that I've encountered:
- The
mywindow.print()
function is triggered before the page has fully loaded, resulting in the material not being visible in the window when attempting to print (selecting "Print" still works correctly). - When the print dialog box opens, it obstructs the contents of the window. How can this be positioned?
Any assistance would be greatly appreciated. Thank you!