我可以让 JavaScript 选择要使用的打印机吗?

发布于 2024-12-12 00:12:09 字数 397 浏览 0 评论 0原文

可能的重复:
从网络应用打印到特定打印机 < /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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

对不⑦ 2024-12-19 00:12:09

不,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.

ゞ花落谁相伴 2024-12-19 00:12:09

如果您的浏览器是基于 IE 的,您可以使用 meadroid 中的此 activeX:

http://www.meadroid.com /scriptx/index.asp

我过去曾使用过它,它允许控制打印机属性。

以下是 mmeadroid 文档中的示例:

<script>
function printWindow() {
  factory.printing.SetMarginMeasure(2); // set inches
  factory.printing.header = "This is MeadCo";
  factory.printing.footer = "Printing by ScriptX";
  factory.printing.portrait = false;
  factory.printing.leftMargin = 1.0;
  factory.printing.topMargin = 1.0;
  factory.printing.rightMargin = 1.0;
  factory.printing.bottomMargin = 1.0;
  factory.printing.copies = 1;
  factory.printing.printBackground = true;
  factory.printing.Print(false);
  factory.printing.WaitForSpoolingComplete();
  // navigate or close browser here //
}
</script>

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:

<script>
function printWindow() {
  factory.printing.SetMarginMeasure(2); // set inches
  factory.printing.header = "This is MeadCo";
  factory.printing.footer = "Printing by ScriptX";
  factory.printing.portrait = false;
  factory.printing.leftMargin = 1.0;
  factory.printing.topMargin = 1.0;
  factory.printing.rightMargin = 1.0;
  factory.printing.bottomMargin = 1.0;
  factory.printing.copies = 1;
  factory.printing.printBackground = true;
  factory.printing.Print(false);
  factory.printing.WaitForSpoolingComplete();
  // navigate or close browser here //
}
</script>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文