Did you find this useful?
Socialize it today.

JavaScript Print

Monday, April 30, 2012

Giving your users a quick and easy way to print your web page is definitely a nice feature to have. We can use the JavaScript print function. Print is a method of the object "window", window.print(). The JavaScript print function performs the same operation as the print option that you see at the top of your browser window.


Here is an example on how to use the print function with a input element.

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

Here is an example on how to use the print function with a link element.

<a href="javascript:window.print()">
    <img src="printImage.png" />

If you have printer friendly pages (not too many colors or background images), your users will enjoy this feature. While users can easily print without this JavaScript add-on, if you use it wisely, your users will appreciate it.

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.

Recommended Books & Training Resources

Professional JavaScript for Web Developers Murachs JavaScript and DOM Scripting JavaScript and jQuery: The Missing Manual