我正在用 javascript 做这样的事情,以在单击链接时打印我的页面的一部分
function printDiv() {
var divToPrint = document.getElementById('printArea');
var newWin = window.open();
newWin.document.write(divToPrint.innerHTML);
newWin.print();
newWin.close();
}
它在 Firefox 中运行良好,但在 IE 中运行不佳。
有人可以帮忙吗
最佳答案
在 newWin.document.write(divToPrint.innerHTML)
之后添加这些行
newWin.document.close();
newWin.focus();
newWin.print();
newWin.close();
然后打印功能将在所有浏览器中工作...
关于javascript - window.print() 在 IE 中不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2555697/