ie print没反应,window.print()在IE中不起作用

痛定思痛。 2023-01-24 02:25 64阅读 0赞

![Image 1][]

I am doing something like this in javascript to print a section of my page on click of a link

function printDiv() {

var divToPrint = document.getElementById(‘printArea’);

var newWin = window.open();

newWin.document.write(divToPrint.innerHTML);

newWin.print();

newWin.close();

}

It works great in Firefox but not in IE.

Could someone please help

解决方案

Add these lines after newWin.document.write(divToPrint.innerHTML)

newWin.document.close();

newWin.focus();

newWin.print();

newWin.close();

Then print function will work in all browser…

[Image 1]:

发表评论

表情:
评论列表 (有 0 条评论,64人围观)

还没有评论,来说两句吧...

相关阅读

    相关 IE浏览器挂

    一个flex开发的应用,只有在IE(目前只在IE8和IE9中测试)中浏览时,发现有好些资源加载不上,在F12工具里查看发现是请求被挂起,一段时间后就会终止,(此时的IE的请求并