The following lines of code create an html page in a browser popup and then prints the popup for the user:
function printPage(htmlPage)
{
var w = window.open("about:blank");
w.document.write(htmlPage);
w.print();
}
This code successfully opens a print dialog in both Firefox and Chrome. However, in IE, no print dialog is displayed. Any suggestions?
I've also tried closing the popup after calling print(), as others have suggested fixes the issue:
function printPage(htmlPage)
{
var w = window.open("about:blank");
w.document.write(htmlPage);
w.print();
w.close();
}
To no avail.
close()
the document
before you try to print()
.
function printPage(htmlPage)
{
var w = window.open("about:blank");
w.document.write(htmlPage);
w.document.close();
w.print();
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.