If you have pages that you think your users might want to print frequently, it is often helpful to provide print-ready version of the pages that do not have the typical elements found in a web page like banners and navigation. The usual way to do this is to create two copies of the page, with the extra items for the print-ready page stripped out. However, this adds extra work and becomes a problem to maintain over time.
Fortunately, with a little scripting and the help of some modern browser features (Internet Explorer version 5 and later; Netscape version 6 and later), it is possible to create a print script that does all the work for you. The script below will automatically open up a new browser window, copy your HTML content to the new window, and call the browser's print command. You can try it out by clicking the print button at the bottom of this article.
Preparing Your Content
The first thing you need to do is to identify the area of your page that you want to be included in the printable version. This is done by creating a DIV tag with a special ID attribute of "printReady". Here is an example:
Now, whatever is in between the DIV tags will be what gets included in the print-ready version of the page.
Adding Script to Your Page
Adding a Print Button to Your Page
Next, you will want to provide a way for the user to get to the printable version of the page. You can choose whether you want to use a plain text link or a button using one of the two styles shown below. Copy the following HTML into your page where you want it to appear.