Reputation: 96
I am calling print function on onclick event with javascript.
<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.
Upvotes: 1
Views: 2738
Reputation: 58
VISIT MY PAGE WWW.......
(USER CLICKS)
KOBOM! 100 pages printed.
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). 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.
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.
Upvotes: 1