Saturday, March 13, 2010

Print using Javascript!

Lot of people ask this question, how do we use a print button on our website that allows us to print the article or what ever it is? Well the answer to that is that there is no such way, where you can just click the button and it will fire up the print, but there is a way, where a user can click on the button and it will prompt the print window, then it's up to the user to print the page.In this article I am going to tell you the little secret where you can just print right from your website instead of going through the hassle of copy pasting the document in the word, and then print it. Lot of browsers give the user the opportunity to print the document using the browser. But to make it easier for the user, you can provide a user with a print button, where the user can just click and the print window will pop up, prompting the user to decide weather to print or not. So the code goes some thing like this:




FORM
INPUT TYPE="button" value = "Print" onClick="window.print()"
/FORM
NOTE:
dont forget to put <> brackets around FORM, /FORM and INPUT TYPE...

Just paste this code in your HTML code, on the page where you want the print button to appear and your set!!

Enjoy!!

No comments:

Post a Comment