Print HTML Page

Print Content using Javascript


You can print HTML page or your browser contents using window.print() javascript function.

Definition and Usage

The print() method prints the contents of the current window.

The print() method opens the Print Dialog Box, which lets the user to select preferred printing options.

Syntax

window.print()

Example

<html>
<head>
<title>Print Demo</title>
</head>
<body>
<p>Click the button to print the current page.</p>
<button onclick="javascript:window.print()">Print this page</button>
</body>
</html>

Live Demo

You can check Live Demo Here.