The task is to print the content of the current window by using the window.print() method in the document. It is used to open the Print Dialog Box to print the current document. It does not have any parameter value.
Syntax:
window.print()
Example: This example representing how to print the content of current window using JavaScript.
<!DOCTYPE html> <html> <body> <h1>Hello GeeksForGeeks Users</h1> <h3> Print the content of the current window using HTML and JavaScript </h3> <form> <input type="button" value="Print" onclick="print_current_page()" /> </form> <script type="text/javascript"> function print_current_page() { window.print(); } </script> </body> </html> |
Before Clicking On Print Button:

After Clicking On Print Button:


Supported Browser are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safri
Recommended Posts:
- How to close current tab in a browser window using JavaScript?
- Print current day and time using HTML and JavaScript
- Print the content of a div element using JavaScript
- How to print the content of an object in JavaScript ?
- JavaScript | Window print() Method
- How to get the size of screen, current web page and browser window using jQuery?
- Javascript | Window Open() & Window Close Method
- Javascript | Window Blur() and Window Focus() Method
- How to get the current URL using JavaScript ?
- How to get the current date in JavaScript ?
- How to get the first and last date of current month using JavaScript ?
- How to list all the cookies of the current page using JavaScript ?
- How to get current formatted date dd/mm/yyyy in JavaScript ?
- How to get current formatted date dd/mm/yyyy in Javascript and append it to an input?
- How to clear the content of a div using JavaScript?
- How to change the Content of a <textarea> using JavaScript ?
- HTML content modification using Javascript
- How to get HTML content of an iFrame using JavaScript ?
- How to open URL in a new window using JavaScript ?
- JavaScript BOM | Window Screen
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


