简体   繁体   English

如何在没有打印预览窗口的情况下进行打印

[英]How to Printing Without Print Preview Window

I am calling print function on onclick event with javascript. 我正在用JavaScript在onclick事件上调用打印功能。

    <input type="button" value="Print" onclick="window.print()" />

I use this code for printing a page but i want to pass 'print preview' window. 我使用此代码打印页面,但我想通过“打印预览”窗口。

How to print directly to default printer without opening dialog box of print. 如何在不打开打印对话框的情况下直接打印到默认打印机。

VISIT MY PAGE WWW....... 访问我的网页WWW .......

(USER CLICKS) (用户点击)

KOBOM! KOBOM! 100 pages printed. 已打印100页。

It should not be possible because it would otherwise be a security issue(this case; spam). 这应该是不可能的,因为否则将是一个安全问题(本例为垃圾邮件)。 Your code involves I/O-communcation and this goes via the browser(everything goes through the browser but here they take control from your code). 您的代码涉及I / O通讯,并且通过浏览器进行(所有内容都通过浏览器进行,但此处它们从您的代码中进行控制)。 You are actually doing it right, but the browser you have chosen have decided to popup a dialog box and wait for the user to accept the print command. 您实际上是在正确地做,但是您选择的浏览器决定弹出一个对话框,等待用户接受打印命令。

Well,the browser designer wants a good user experience for their users and in this way they prevent potential spam. 好吧,浏览器设计师希望为其用户提供良好的用户体验,并以此方式防止潜在的垃圾邮件。 Javascript knows it and thats why there is no parameters for this in the printer function. Javascript知道这一点,这就是为什么打印机功能中没有此参数的原因。

You still want to do it? 你还想做吗? try to find an add-on or a tweak for your current browser to allow such bypasses. 尝试为您当前的浏览器找到插件或调整项,以允许绕过此类行为。 Create your own application(could be a browser). 创建自己的应用程序(可以是浏览器)。

Issue with this approach? 这种方法有问题吗? You dont want to ask other users to install or configure such things; 您不想让其他用户安装或配置此类东西; Too much for the average user and your intent was to make things easier. 对于普通用户来说太多了,您的意图是使事情变得容易。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM