---
title: "Java Script – Page Printing"  
description: "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 th"  
author: "Danish Khan"  
published: 2012-10-20  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/382/java-script-page-printing  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# Java Script – Page Printing

##### Introduction:

In this [article](https://www.mindstick.com/articles/95867/are-you-looking-for-500-credit-score-mortgage-lenders-houston-continue-reading-this-article) I am going to [explain](https://www.mindstick.com/forum/157854/what-is-system-debugging-explain-some-system-debugging-tools-used-in-modern-computer-systems) how to print the [content](https://www.mindstick.com/articles/13019/get-the-best-content-marketing-pricing-packages-for-your-brand) of the [web page](https://www.mindstick.com/forum/718/sql-server-report-alignment-to-center-of-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](https://www.mindstick.com/blog/178/synchronous-and-asynchronous-command-execution-in-c-sharp-dot-net) just on clicking a button. Java Script also provides this with the help of window.print() [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server).

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](https://www.mindstick.com/forum/790/form-gets-submiited-twice-on-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](https://www.mindstick.com/articles/12876/the-top-5-reasons-to-buy-and-install-a-tonneau-cover) it.

![Java Script – Page Printing](https://www.mindstick.com/blogs/e84339ea-8416-4a8a-87bb-26d8b64518be/images/55c0a618-d3b4-4209-b505-18143988bafa.png)

##### Conclusion:

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

web page content through

printer on a paper.

---

Original Source: https://www.mindstick.com/blog/382/java-script-page-printing

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
