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
Click the Tools icon in Internet Explorer. Click the Security tab and uncheck the checkbox beside Enable Protected Mode (requires restarting Internet Explorer) Click Apply , and then click OK. Close all open Internet Explorer windows, and then restart Internet Explorer.
Print pages by pressing Crtl + P on the keyboard or select the Tools button > Print, and then choose Print. You can also see what the printed page will look like by selecting Print Preview. To print only a picture from a page (and not the whole page), right-click the picture, and then select Print.
The common reasons if the web browsers are not printing could be due to: Conflicts with Add-ons. Incompatible driver Components. Incorrect Printer software settings.
If your Chromebook can't load the print preview, restart your laptop, printer, and router. Additionally, remove and set up the printer again. If the issue persists, clear your Chrome cache, and disable your extensions. You can also reset your browser to default settings.
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...
Add newWin.document.close();, like so:
function printDiv() {
var divToPrint = document.getElementById('printArea');
var newWin = window.open();
newWin.document.write(divToPrint.innerHTML);
newWin.document.close();
newWin.print();
newWin.close();
}
This makes IE happy. HTH, -Ted
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With