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...