JavaScript Page Printing - Java Script

What is JavaScript Page Printing?

One would like to print their desired content of web page,through actual printer. This is possible by placing a print button while creating a web page itself. JavaScript assists you in implementing this functionality using the print function of window object.

Window.print function in JavaScript prints the current web page when executed. Onclick event also assists you to call this function directly.
Example:
Try the below example.
Output:

Although window.print serves the purpose of getting a printout, it is not advisable.

A printer friendly webpage is a page with no graphics, advertising, images, but just the text . One can make a page printer friendly in the below ways −

  • Make a copy of the page one desired and then clear out the unnecessary text and graphics. Then link this page to the actual printer and get friendly page content from the original.

  • If one does not want to keep an extra copy of a page, then they can mark their printable text using proper comments like<!-- PRINT STARTS HERE -->..... <!-- PRINT ENDS HERE -->and then one can use PERL or any other script in the background to clear the printable text and final printing page is displayed. We at wisdom jobs use window.print method to provideprint facility to our site visitors.

How to Print a Page?

If one does not identify the above competency on a web page, then they can use the

standard browser's toolbar to get your web page printed.

Below is the link which illustrates on how to print a page.
File→Print→Click OK button.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Java Script Topics