【发布时间】:2017-08-11 22:54:16
【问题描述】:
我有一个 Angular js 应用程序,对于打印功能,我正在使用 window.open 方法打开一个 html 页面。
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;
};
我在 html 页面上有一个打印按钮。我使用onclick事件来调用print。
<button class="print-btn" onclick="window.print();" id="view_print"> Print</button>
此代码在 Chrome 中完美运行,但在 IE 11 中无法正常运行。如果我将默认设置从 Edge 更改为 IE 10,打印似乎可以正常工作并打开打印对话框窗口。它肯定比 Chrome 慢。
我已尝试添加如下仿真(对于 IE 10 和 8 等),但它仍然无法正常工作。
我在这里遗漏了什么吗?我找到了很多文章,但我一直无法修复它。
【问题讨论】:
-
什么不起作用?
-
应该来选择打印机的打印对话窗口没有出现。它在 chrome 上表现良好。
-
如果你把
type="button"加到按钮上,会有什么不同 -
不,它没有。
-
并且控制台没有报错,页面上也没有id为“print”的项目?
标签: javascript html angularjs internet-explorer printing-web-page