Users Pricing

blog

home / developersection / blogs / java script – page printing

Java Script – Page Printing

Danish Khan 4147 20 Oct 2012 Updated 18 Sep 2014
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.

Java Script – Page Printing

Conclusion:

From this tutorial we came to know how Java Script provides us to print

web page content through

printer on a paper.


Danish Khan

Other