Possible Duplicate:
How can Print Preview be called from Javascript?
I have a button on the screen which should call a JavaScript function.
<input class="btn-print" type="button" value="Print" onclick="PrintPreview()">
This should open a new window with the Print Preview screen, just as you would if you went to File>Print>Print Preview in FF. File>Print Preview in IE.
To print a page in JavaScript, use the print() method. It opens up the standard dialog box, through which you can easily set the printing options like which printer to select for printing.
To print the content of div in JavaScript, first store the content of div in a JavaScript variable and then the print button is clicked. The contents of the HTML div element to be extracted.
No can do. The most you can do with javascript is
window.print();
To popup the print dialog.
This is a feature of the browser and it would be a security risk to allow it. Therefore, most browsers will not allow it.
how-can-print-preview-be-called-from-javascript is another question that asked the same thing.
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