window.print()

Nav4+, IE4+ Syntax

							window.print()

Description

The print() method of the Window object simulates the user clicking the Print button on the browser. It tells the browser to open the print dialog box to print the current page.

Example

Listing 7.572 has a button. Clicking the button will tell the browser to open the Print dialog box to allow the user to print the current page.

Listing 7.572 Using the print() Method to Print the Current Page
<html>
<body>
<form>
  <input type=BUTTON value="Print" onClick="window.print()">
</form>
</body>
</html>
							
						

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.