Print A Web Page Automatically Using Firefox

If you need to print a web page automatically with Javascript and you don't want the user to see a print dialog box, you can do that with Mozilla Firefox if you change a user's setting in Firefox:


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> 

NOTE:  THIS DOES NOT AFFECT WHAT HAPPENS WHEN A USER JUST HITS THE PRINT BUTTON.   ONLY WHEN YOUR HTML CODE CALLS THE JAVACRIPT PRINT COMMAND.


Comments