javascript IE 中的 Window.print() 错误 res://ieframe.dll/preview.js

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10899436/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 11:24:54  来源:igfitidea点击:

Window.print() error in IE in res://ieframe.dll/preview.js

javascripthtmlinternet-explorerwindow

提问by user942309

Onclickof a anchor tag i am giving window.print();call and I get the print pop-up. But on the click of print I get the following script error.

Onclick一个锚标签,我正在window.print();打电话,我得到了打印弹出窗口。但是在单击打印时,我收到以下脚本错误。

An error occurred in the script on this page.
Line: 2115
Char: 1
Error: Your file waiting to be printed was deleted.
Code: 0
URL : res://ieframe.dll/preview.js

Do you want to continue with the script on the page(yes/no buttons)

是否要继续页面上的脚本(是/否按钮)

May what ever you click Yes/No I don't get the print or in IE8 i get a blank print.

可能你点击是/否我没有得到打印或在 IE8 中我得到一个空白打印。

Firefox prints fine. But, fails in IE9.

Firefox 打印正常。但是,在 IE9 中失败。

Can some one help me on this one??

有人可以帮我解决这个问题吗??

回答by Ed Spencer

You can also get this error in IE10 if you are calling window.close()immediately after window.print(), especially if your DOM is large. My guess is that the page has not finished rendering when IE10 executes the window.print()call.

如果您在window.close()之后立即调用window.print(),您也可能在 IE10 中收到此错误,尤其是当您的 DOM 很大时。我的猜测是IE10执行window.print()调用时页面还没有完成渲染。

You can therefore get around this issue by:

因此,您可以通过以下方式解决此问题:

  • Calling window.close()within a hover event on the page. A print dialgue will steal the user's focus, so the hover event wont fire until the user has finished dealing with the dialogue. We found this to be the best solution.
  • Not calling window.close()at all for IE10 clients
  • As window.print()does not have a callback, calling window.close()after an arbitrary delay. I wouldn't recommend this as it will be unreliable
  • Go "nuclear" with this answer, which loads the html into a hidden iFrame before printing, sidestepping the need to call window.close()
  • window.close()在页面上的悬停事件中调用。打印对话会窃取用户的注意力,因此在用户完成对话处理之前不会触发悬停事件。我们发现这是最好的解决方案。
  • 根本不调用window.close()IE10 客户端
  • 由于window.print()没有回调,window.close()在任意延迟后调用。我不会推荐这个,因为它不可靠
  • 使用此答案“核”,在打印之前将 html 加载到隐藏的 iFrame 中,避免调用window.close()

回答by powtac

Follow this two Microsoft help articles:

请遵循以下两篇 Microsoft 帮助文章:

At least it seems to be a problem with print driver and or problems with add ons installed in the IE. An other solution is to be uninstall IE 9 and reinstall it.

至少它似乎是打印驱动程序的问题和/或 IE 中安装的附加组件的问题。另一种解决方案是卸载 IE 9 并重新安装。

回答by Dave Parker

I ended up replacing/upgrading the printer driver on the server end, removing the printer on the desktop client and recreating the printer via the handy UNC path (double \ which doesn't show here) \server\printer" add method.

我最终更换/升级了服务器端的打印机驱动程序,删除了桌面客户端上的打印机,并通过方便的 UNC 路径(双 \ 此处未显示)\server\printer" 添加方法重新创建打印机。