Friday, November 21, 2025
HomeLanguagesJavascriptHow to print the content of current window using JavaScript ?

How to print the content of current window using JavaScript ?

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()

Parameters: No parameters are required

Returns: This function does not return anything

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

html




<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>


Output:

 

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32405 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6781 POSTS0 COMMENTS
Nicole Veronica
11928 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11997 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7166 POSTS0 COMMENTS
Thapelo Manthata
6862 POSTS0 COMMENTS
Umr Jansen
6847 POSTS0 COMMENTS