JavaScript helps you to implement this functionality using print function of window object.
The JavaScript print function window.print() will print the current web page when executed. You can call this function directly using onclick event as follows:
<head> <script type="text/javascript"> <!-- //--> </script> </head> <body> <form> <input type="button" value="Print" onclick="window.print()" /> </form> </body> |
You can do one of the followings to make a page printer friendly:
- Make a copy of the page and leave out unwanted text and graphics, then link to that printer friendly page from the original. Check Example.
- If you do not want to keep extra copy of a page then you can mark
your printable text using proper comments like <!-- PRINT STARTS
HERE -->..... <!-- PRINT ENDS HERE --> and then you can use
PERL or any other script in background to purge printable text and
display for final printing. Our site is using same method to give print
facility to our site visitors. Check Example.
How to print a page:
If someone is providing none of the above facilities then you can use browser's standard toolbar to get web pages printed out. Follow the link as follows:File --> Print --> Click OK button.
- http://www.tutorialspoint.com/
No comments:
Post a Comment