MS Edge - window.print () is not a context context in the MS edge

Microsoft Edge does not process window.print () sequentially compared to other browsers.

Most browsers that call window.print () from an iframe on the page will only print the contents of this iframe. However, the entire document will always be printed in the region.

Was it intentional? Is there a workaround?

JSFiddle example.

iframe.html

... <body> <a href="#" onclick="window.print()">print iframe document</a> </body> ... 

index.html

 ... <body> <a href="#" onclick="window.print()">print outer document</a> <iframe src="iframe.html"></iframe> </body> ... 
+7
javascript html microsoft-edge printing iframe
source share
3 answers

This is a confirmed problem with microsoft, quote:

 Posted by Microsoft on 7/29/2015 at 12:46 AM We were able to confirm the issue, and will be working to resolve it in a future release 

A workaround does not yet exist.

+6
source share

We have a magic solution:

 parent.document.getElementsByName("pdfjs-frame")[0].contentWindow.document.execCommand("print", false, null); 

... works in IE, EDGE, Chrome. The other has not yet been tested.

+3
source share

In IE too. You can fix it.

 window.top.document.getElementById("iframe-id").contentWindow.focus(); window.top.document.getElementById("iframe-id").contentWindow.print(); 

It is tested .;)

-one
source share

All Articles