Home > DeveloperSection > Blogs > Java Script – Page Printing

Java Script – Page Printing


JavaScript JavaScript 
Ratings:
0 Comment(s)
 1972  View(s)
Rate this:

Java Script – Page Printing

Introduction:

In this article I am going to explain how to print the content of the web page. There are times when we want to print the content of the webpage on the paper. We would like to give a print command just on clicking a button. Java Script also provides this with the help of window.print() function.

The Java Script window.print() will print all the content of the current web page when that function is executed. This function will be called on the button click event which I will show you in the example given below.

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

</head>

<body>

    <div>

        <input id="btnPrint" type="button" value="Print" onclick="window.print()" />

    </div>

</body>

</html>

We have called window.print() function on the button click. As soon as we will click on the button Print dialog will open. If printer is not installed then we have to install it.

Conclusion:

From this tutorial we came to know how Java Script provides us to print web page content through printer on a paper.


Don't want to miss updates? Please click the below button!

Follow MindStick