Supertext Home
Chief of the System Blog

Print a web page with Javascript

April 7th, 2008 by

On a lot of pages you see a Print link, which then opens the print window. This can be achieved very easy:

window.print() Or built into a Link: <a href="javascript:window.print()"> Click to print this page </a>

If you put the print() command into the onload event of the body tag, the print command will fire automatically. This is handy if you want to format your page differently for print than for the browser.

I’ve built a little live example here.

Related Posts

  1. HTML Entity Character Lookup
  2. Breadcrumbs to indicate the Checkout Progress
  3. Float Drop Problem

Leave a Reply

  • Topics
  • Archive
  • Subscribe
  • Facebook
  • Twitter