Print a web page with JavaScript

From The IT Community
Jump to: navigation, search

Here is how to print a web page with JavaScript:

To print a html page a soon as it loads, put the following into the <body> tag of site:

<body onload="self.print()">

If you want the user to click on a link to print the page use this:

<a href="javascript:self.print()">print this page</a>

To see what to do if JavaScript is not enabled, check out the article "Deal with disabled JavaScript support".

Was this article helpful? Then please donate to keep The IT Community alive...

If you found this article helpful please share it, comment and help others by writing your own article.

Translate this page:

Articles found in the same category:
(max. 20 shown)