Abi P
Abi P

Reputation: 1450

window.print() does not work in IE 11

I have an angular js app and for a print functionality I am opening an html page using the window.open method.

 public openNewWindow(html: string, title: string) {
    var popupWin = window.open('', '_blank', 'scrollbars=no,menubar=no,toolbar=no,location=no,status=no,titlebar=no, height=500, weidth=900');
    popupWin.window.focus();
    popupWin.document.write(html);
    popupWin.document.title = title;
};

I have a button on the html page to Print. I use the onclick event to call print.

 <button class="print-btn" onclick="window.print();" id="view_print"> Print</button>

This code perfectly works in Chrome, but not in IE 11. If I change the default from Edge to IE 10 the print seem to be working and opening the print dialog window. It is definitely slower than the Chrome.

I have tried adding the emulation as below (for IE 10 and 8 etc) but it still does not work.

am I missing anything here? I find a lot of articles but I have not been able to fix it.

Upvotes: 0

Views: 6987

Answers (3)

MarmiK
MarmiK

Reputation: 5775

If you have new system, and after trying everything this is not working out,

Try setting Printer First.

Set Default Printer and your IE should start responding to

"Ctrl" + "P" 

or

window.print()

Upvotes: 0

S.Donovan
S.Donovan

Reputation: 11

I am seeing this also, but with the following information:

  • under Chrome: address at bottom of page is (the correct) http://server/path/file.php?querystring
  • under IE11: address at bottom of page is http://server/path/{8 digit dynamic alphanumeric string}.htm

The onscreen rendering is correct, but the printed result is a 404 error.

The current work around is to use Chrome.

Upvotes: 0

Rob Parsons
Rob Parsons

Reputation: 839

Scripted popup windows with size and position parameters are subject to Popup blocker and IE Security zone restrictions. try

window.open('', '_blank');

Use the File>Properties menu to determine which IE Security zone a web page/domain maps to.

See any Wikipedia article side bar for a template method of formatting the current web page in a printer friendly format using media queries.

Upvotes: 1

Related Questions