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
I was told to do document.close after document.write, I dont see how or why but this caused my script to wait until I closed the print dialog before it ran my window.close.
I've had this problem before, and the solution is simply to call window.print() in IE, as opposed to calling print from the window instance:
This worked for me, it works in firefox, ie and chrome.
I am also facing this problem.
Problem in IE is newWin.document.write(divToPrint.innerHTML);
when we remove this line print function in IE is working. but again problem still exist about the content of page.
You can open the page using window.open, and write the content in that page. then print function will work in IE.This is alternate solution.
Best luck.
@Pratik