Print a web page automatically (IE Only)

NOTE: THIS CODE IS OLD. MAY NOT WORK FOR NEWER VERSIONS OF IE.

If you want to have a "print page" button on a web page, and you want it to print automatically, without getting the "print dialog" box on your computer, you can use this code, but it only works for Internet Explorer:

<html>

<head>

<title>Print Test</title>

<script>

function Print()

{

if (document.all)

{

WebBrowser1.ExecWB(6, 2) //use 6, 1 to prompt the print dialog or 6, 6 to omit it;

WebBrowser1.outerHTML = "Devin";

}

else

{

window.print();

}

}

</script>

</head>

<body>

<object ID="WebBrowser1" WIDTH="0" HEIGHT="0"

CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">

</object>

<A HREF="#" onClick="Print()">Print this page</a>

</body>

</html>

IF YOU ARE USING MOZILLA:

A user can set a preference to print without dialog box.

Go to about:config (Type this in the address bar)

Right click on any preference and select "NEW" > "BOOLEAN" IMPORTANT: DO NOT SELECT STRING or NUMERIC as this will not work if you are an idiot (like me) and select "STRING"

type: print.always_print_silent

Hit OK

type: true

Restart the browser. This writes a line to the prefs.js file (on windows) (or the user.js file on Linux?) the next time you start the browser, any javascript print(); command will print directly to the printer using the currently configured print settings. The exact syntax is:

<a href="#" OnClick="window.print();">PRINT THIS WINDOW</a>