簡體   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