在JavaScript中使用Chrome中的系统打印对话框 [英] Use System Print Dialog in Chrome in JavaScript

查看:736
本文介绍了在JavaScript中使用Chrome中的系统打印对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个问题,Chrome的打印预览不能正确打印我们的页面。如果您使用使用系统打印对话框(Ctrl + Shift + P),它会打印出我们的页面(几乎与Firefox相同)。



我们有一个按钮在我们的页面上调用window.print()来打开打印对话框。但是,在Chrome中,它会打开到打印预览对话框,从而导致不能正确打印我们的页面。

是否有JavaScript可直接打印到Chrome的系统打印对话框中?




我知道最终用户如何禁用chrome://标记中的打印预览,但是我想知道的是,无论如何,当我以编程方式调用window.print()(或类似的)时,无论用户设置如何。

解决方案

使用JavaScript打印对话框无法编写脚本。它们是浏览器本身的专有部分。


We have an issue where Chrome's "Print Preview" does not print our pages correctly. If you use the "Use System Print Dialog link" (Ctrl+Shift+P), it prints our page fine (almost identically to Firefox).

We have a button on our page that calls window.print() to open the print dialog. However, in Chrome it opens to the "Print Preview" dialog which ends up not printing our page correctly.

Is there away with JavaScript to print directly to the "system print dialog" in Chrome?

P.S. I do know how the end user can disable the Print Preview in chrome://flags, but what I want to know is there anyway to prevent it from showing when I programmatically call window.print() (or similar) regardless of user settings.

解决方案

Print dialogs are not scriptable using JavaScript. They're proprietary parts of browsers themselves.

这篇关于在JavaScript中使用Chrome中的系统打印对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆