我正在用javascript做一些类似的事情,在点击链接时打印页面的一部分。
function printDiv() {
var divToPrint = document.getElementById('printArea');
var newWin = window.open();
newWin.document.write(divToPrint.innerHTML);
newWin.print();
newWin.close();
}
它在Firefox中工作得很好,但在IE中就不行了。
有没有人能帮帮忙
发布于 2011-05-18 14:38:18
将这些行添加到newWin.document.write(divToPrint.innerHTML)
之后
newWin.document.close();
newWin.focus();
newWin.print();
newWin.close();
然后打印功能将在所有浏览器中工作...
发布于 2012-06-15 18:00:20
function printDiv() {
var divToPrint = document.getElementById('printArea');
newWin= window.open();
newWin.document.write(divToPrint.innerHTML);
newWin.location.reload();
newWin.focus();
newWin.print();
newWin.close();
}
发布于 2011-09-02 23:48:52
我以前遇到过这个问题,解决方案是简单地在IE中调用window.print(),而不是从窗口实例调用print:
function printPage(htmlPage)
{
var w = window.open("about:blank");
w.document.write(htmlPage);
if (navigator.appName == 'Microsoft Internet Explorer') window.print();
else w.print();
}
https://stackoverflow.com/questions/2555697
复制相似问题