Javascript window.print()在IE 11中不起作用
我有一个angular js应用程序,为了实现打印功能,我使用window.open方法打开了一个html页面Javascript window.print()在IE 11中不起作用,javascript,html,angularjs,internet-explorer,printing-web-page,Javascript,Html,Angularjs,Internet Explorer,Printing Web Page,我有一个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')
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中完美地工作,但在IE11中却不行。如果我将默认值从Edge更改为IE 10,打印似乎正在工作,并打开打印对话框窗口。它肯定比Chrome慢
我已经尝试为IE 10和8等添加如下模拟,但仍然不起作用。
我有什么遗漏吗?我找到了很多文章,但我无法修复它。带有大小和位置参数的脚本弹出窗口受弹出窗口阻止程序和IE安全区域限制。试一试 window.open,“u blank” 使用文件>属性菜单确定网页/域映射到哪个IE安全区域
查看任何维基百科文章侧栏,了解使用媒体查询以打印机友好格式格式化当前网页的模板方法。我也看到了这一点,但包含以下信息: 在Chrome下:页面底部的地址是正确的http://server/path/file.php?querystring 在IE11下:页面底部的地址是http://server/path/{8位动态字母数字字符串}.htm 屏幕上的渲染是正确的,但打印的结果是404错误
当前的解决方法是使用Chrome。如果您有新系统,并且在尝试了所有不可行的方法后 请先尝试设置打印机 设置默认打印机,IE将开始响应
"Ctrl" + "P"
或
什么不起作用?应用于选择打印机的打印对话框窗口未出现。它在chrome上的行为正常。如果在按钮上添加type=button,是否会产生差异?如果没有,控制台中没有错误,页面上没有id打印的项目?
window.print()