Home : Internet : JavaScript : Print

How to Print a Page With JavaScript

The method for printing the page is window.print();

This opens the user's print window. Use it with any event handler such as onClick :

<input type="button" value="Print This Page" onClick="window.print()">


Printer Settings

A common question is how to control the user's printer settings using Javascript. The common answer is that you can't. Javascript is not designed to take control of computer hardware.

There are some third-party solutions available which offer simple printer setting controls (e.g. ScriptX External Link). These solutions can work well in controlled situations but are not practical for general website use.

Unfortunately the best advice we can give about controlling printer settings is not to try. People are in charge of their printers just as they are in charge of their monitors and other hardware. Learn to accept that some things are always in the hands of the end user.

Subscribe to us on YouTube