Skip to content
Related Articles

Related Articles

Improve Article

How to print the content of current window using JavaScript ?

  • Last Updated : 09 Jul, 2020

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.



Example: This example representing how to print the content of current window using JavaScript.

<!DOCTYPE html>
    <h1>Hello GeeksForGeeks Users</h1>
        Print the content of the current 
        window using HTML and JavaScript
        <input type="button" value="Print" 
            onclick="print_current_page()" />
    <script type="text/javascript">
        function print_current_page() {

Before Clicking On Print Button:

After Clicking On Print Button:

Supported Browser are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safri

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :