Monday, August 18, 2008

JavaScript: Print Button on Your Web Page

It is fairly simple to add a PRINT Button on your web pages using JavaScript. The best practise to provide the facility of printing on web page is to provide a page that does not contain the banners/headers/footers/menus etc.
For this just create another web page containing only the data you actually need to print; For this make sure the background is not dark or does not contains the darked background image. etc

You can use simple JavaScript built in method window.print(). For example the following code segment will place a print link on your webpage using the img tag of HTML.

< i m g onclick="window.print();" src="/images/PrinterIcon.gif"
style="cursor:hand;" />

(Replace the text /images/PrinterIcon.gif with the location of an icon in your site.)

5 comments:

Robert John said...

this is great, since i am not that familiar with javascript.

anyway, can we also put a print preview button on a webpage?

how can we do this?

Yousufzai said...

What is great respecting is dealing with instead of depending on. nyc web designer

julie lars said...

Please keep on posting such quality storys as this is a rare thing to find these days. I am always searching online for posts that can help me. watching forward to another great website. Good luck to the author! all the best! nyc web designer

sdexter said...

Very good publish, thanks a lot for sharing. Do you happen to have an RSS feed I can subscribe to? san francisco brand agency

william locas said...

The luxury proposed might be incomparable; citizens are never fail to looking for bags is a Native goals. The idea numerous insert goals uniquely to push diversity with visibility during the travel and leisure arena. Hotels Discounts ui design agency san francisco