How to add a PRINT button to your web page.

Print Button

You can easily add a print button or link to your web page. To add a button use the following code:

onclick="window.print();return false;" />

The button looks like this:

To add a link you code it like this:

The link looks like this: print

You can also easily control what parts of your page print out by adding a special stylesheet that will be used for printing to the head section of your page like this:

type="text/css" media="print" />

The print.css file should contain the following:

body {visibility:hidden;}
.print {visibility:visible;}

Now all you need to do is to assign class="print" to whatever parts of your web page that you want to have print out. Anything on the page not assigned to this class will not print.

Try printing this page to see how it works.

 

The original page with this information is at http://javascript.about.com/library/blprint.htm

  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

be on the lookout for these common grammatical slip-ups

Takeaway: Sending a less-than-perfect e-mail to a friend is one thing; mistakes aren't really a...

Font Basics for Branding Your Small Business

There are many components of a brand identity: logo, color palette, font choice, and the Visual...

Change The Default Index Files!

Change Default Index Files Most web-domains setup your account to use a specific file extension...

Website traffic statistics

Question:I was hoping to find out how many hits the website gets. How do I go about checking the...