5

Possible Duplicate:
“Silent” Printing in a Web Application

I'd like the window.print() command to print directly, without opening the print window:

enter image description here

Is that possible?

Community
  • 1
  • 1
Lea Cohen
  • 7,990
  • 18
  • 73
  • 99
  • It's possible in IE but not in the other browsers. – Christoph Jul 09 '12 at 08:09
  • @Esailija : I understand what you're saying. However in my site, I wasn't planing to run that command on `OnLoad`. The plan was to create a button that calls the `window.print` command, and save the user from having to click on yet another button.... – Lea Cohen Jul 09 '12 at 08:22
  • @LeaCohen ok, so when you visit some random site and just click once anywhere, they could make your computer to print automatically? It isn't much of an improvement on the security side. – Esailija Jul 09 '12 at 08:25
  • @Esailija, I totally agree with you. – Lea Cohen Jul 09 '12 at 08:26

2 Answers2

6

try

For Mozilla : http://forums.mozillazine.org/viewtopic.php?t=48336

When you use JavaScript's window.print() to print a Web page in IE, by default, it prompts IE's printer dialog box. To avoid this, use the following JavaScript code:

if (navigator.appName == "Microsoft Internet Explorer")
{
var PrintCommand = '<object ID="PrintCommandObject" WIDTH=0 HEIGHT=0
CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
document.body.insertAdjacentHTML('beforeEnd', PrintCommand);
PrintCommandObject.ExecWB(6, -1); PrintCommandObject.outerHTML = "";
}
else {
window.print();
}

from : http://www.devx.com/tips/Tip/30834

Christoph
  • 50,121
  • 21
  • 99
  • 128
Pranay Rana
  • 175,020
  • 35
  • 237
  • 263
4

It called silent printing and you can do it on several browsers but it isn't that simple..

On Fire Fox -

Type about:config at Firefox’s location bar and hit Enter.

Right click at anywhere on the page and select New > Boolean

Enter the preference name as print.always_print_silent and click OK.

Look at the following question:

"Silent" Printing in a Web Application

Community
  • 1
  • 1
Dor Cohen
  • 16,769
  • 23
  • 93
  • 161