繁体   English   中英

MS Edge - window.print()在MS边缘不是帧上下文

[英]MS Edge - window.print() is not frame contextual in MS edge

与其他浏览器相比,Microsoft Edge不会始终如一地处理window.print()。

在大多数浏览器中,从页面上的iframe中调用window.print()只会打印该iframe的内容。 但是在边缘,它将始终打印整个文档。

这是故意的吗? 有解决方法吗?

关于JSFiddle的例子

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

这是微软公认的问题 ,引用:

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

还没有解决方法。

我们有一个神奇的解决方案:

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

...适用于IE,EDGE,Chrome。 另一个尚未测试。

它也在IE中。 你可以像这样解决它。

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

经过测试。 ;)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM