JavaScript Print Button

To implement a print button on a web page, you can use the window.print() javascript function.  The following example shows an image that is displaying a printer icon and will print the current page when clicked.

<img border=”0″ onclick=”window.print();” src=”/images/PrintIcon.gif” style=”cursor:hand;” />
(Replace the text /images/PrintIcon.gif with the location of an icon in your site.)

A better application of this idea is to first create a page that renders a print preview of the information you want to print.  This print preview will look similar to the original page but will not contain navigation items, header images, or other page clutter.  Furthermore, the data can be formatted to fit cleanly on 8.5″ x 11″ paper.  Embed the print icon in the print preview page and allow users to print from there.

This entry was posted in Technology, Uncategorized and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *