Print a web page with Javascript

On a lot of pages you see a Print link, which then opens the print window. This can be achieved very easy:

window.print() Or built into a Link: <a href="javascript:window.print()"> Click to print this page </a>

If you put the print() command into the onload event of the body tag, the print command will fire automatically. This is handy if you want to format your page differently for print than for the browser.

I’ve built a little live example here.

Ähnliche Beiträge

Leave a Reply

Your email address will not be published. Required fields are marked *