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.

Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s