我可以让 JavaScript 选择要使用的打印机吗?
可能的重复:
从网络应用打印到特定打印机 < /p>
一我们的 Intranet 应用程序需要打印到非默认打印机。当然,人们经常忘记选择正确的打印机。
我知道你不能通过 JavaScript 通常执行此操作,但考虑到浏览器是 IE9 并且我可以将 Web 应用程序添加到受信任区域(并随意调整安全设置),有没有办法编写 JavaScript会自动选择正确的打印机吗?也许使用一些 ActiveX 或其他 IE 特定的东西。
Possible Duplicate:
Printing to a specific printer from a web app
One of our intranet applications needs to print out to a non-default printer. Of course people regularly forget to select the correct printer.
I'm aware that you can not do this normally via JavaScript but given that the browser is IE9 and I can add the webapp to the trusted zone (and fiddle around with the security settings at will), is there any way to write JavaScript that will automatically select the correct printer? Perhaps using some ActiveX or other IE specific stuff.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,Javascript 对象模型包含一个 window.print() 方法,该方法可以激活 Web 浏览器的标准打印对话框,但这仅限于功能扩展。 Javascript 代码检查连接到计算机的打印机、查找打印机属性或任意配置其设置是不合适或不安全的。
我建议在打印之前添加一个弹出窗口,提醒用户选择合适的打印机。
No, the Javascript object model includes a window.print() method that may activate the standard print dialogue of a Web browser, but that is as far as the functionality extends. It would not be appropriate or safe for Javascript code to be able to check the printers attached to a computer, look up printer properties or arbitrarily configure their settings.
I suggest to add a pop prior to printing where you remind the user to select the appropiate printer.
如果您的浏览器是基于 IE 的,您可以使用 meadroid 中的此 activeX:
http://www.meadroid.com /scriptx/index.asp
我过去曾使用过它,它允许控制打印机属性。
以下是 mmeadroid 文档中的示例:
If your browser is IE based you can use this activeX from meadroid:
http://www.meadroid.com/scriptx/index.asp
I have used it in the past and it permits to control the Printer attributes.
Here is an example from mmeadroid documentation: