The Web Development Blog has moved to Please visit me there to read the latest entries and to update your bookmarks and RSS feeds.

March 22, 2005

Automatic 'Print this page'

If you want to provide a way for the user to print the current page, include this little javascript snippet.

Of course, they could always just select file > print by themselves... but will they? A good combination is to use this in conjunction with the Javascript - Bookmark this page that is found elsewhere on this site.

This print function is also very useful when you are using frames. Since the browser doesn't always know which of the frames you want printed, and sometimes will only print the top frame you can use this to only send the data that the user will want printed. As long as you think you can predict WHICH of the frames they will want.

Since the javascript exists inside the frame, that's the one that'll be sent to the print que.

How do you do it? Put the following code somewhere on your page, again usually in the upper right.

< a href="#" onClick="window.print()" >Print this page< /a >

Try it next time you need or want to provide another feature on your site. As always though my advice is; don't overuse it!

Hope this helps!

StumbleUpon Toolbar Stumble It! AddThis Social Bookmark Button

Posted by: Kevin Adams March 22, 2005 11:54 AM | Category: Tips and Tricks


Trackback URL for this entry is: Automatic 'Print this page'


Post a comment

Posted by: kla3 (Kevin Adams) March 22, 2005 11:54 AM | Comments (0) | Trackback