The Wayback Machine - http://web.archive.org/web/20220123081019/https://www.geeksforgeeks.org/javascript-window-print-method/amp/

JavaScript | Window print() Method

Page print in JavaScript is a simple code in JavaScript used to print the content of the web pages. 
 

Syntax: 
 

window.print()

Parameters: No parameters required 
Returns: This function do not return anything
The following Javascript code shows a print button and then it shows the property of that webpage in a sheet in which you are going to print it. 
The JavaScript print function window.print() is used here to perform the functionality. 
Example : 
 




<!DOCTYPE html>
<html>
 
<head>
    <title>
        HTML | DOM Window Print() method
    </title>
 
    <script type="text/javascript">
    </script>
 
</head>
 
<body>
 
    <h2>HI GEEKSFORGEEKS USER'S</h2>
    <form>
        <input type="button" value="Print"
               onclick="window.print()" />
    </form>
 
</body>
<html>

Output :
 

But the web pages are not limited to text only. There are other things too in the webpages like images consisting of different colors, etc. Printing such pages can be done by the following ways : 
 

Supported Browser: The browser supported by Window print() Method are listed below: 
 

 

Article Tags :