我知道已经有相同的 question但这些答案都不适合我。
问题:
我有一个适用于 Firefox 的 Angular 应用程序,我在其中打开一个窗口来打印它。 问题是我不想多次打印它,也不希望用户看到该 View 。所以我想打开这个 主应用程序后面的新窗口。
我的代码:
let printContents2, popupWin2;
printContents2 = document.getElementById('to-print').innerHTML;
popupWin2 = window.open('', '_blank', 'top=10000,left=10000,height=1px,width=1px');
popupWin2.document.open();
popupWin2.document.write(`
<html>
<head></head>
<body style='width=350px' onload="window.print();window.close();">${printContents2}</body>
</html>`
);
popupWin2.document.close();
我尝试过的:
popupWin2.blur();
window.focus();
onload="window.print();window.close();"
提前谢谢您。
最佳答案
如果它是一种 Intranet 应用程序,并且您可以强制客户端安装插件,您可以使用插件 https://addons.mozilla.org/firefox/addon/seamless-print/否则,出于安全原因,这是不可能的。您也可以使用基于java的解决方案https://github.com/qzind/tray/wiki/2.0-getting-started这取决于您的情况更适合什么。
关于javascript - 使用 Javascript 在当前窗口后面打开一个窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47479498/