Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto start print html page using javascript

Is there anyway to automatically run javascript:window.print() when the page finishes loading?

like image 640
fmsf Avatar asked Oct 27 '08 22:10

fmsf


People also ask

How do I print a Web page using JavaScript?

To print a page in JavaScript, use the print() method. It opens up the standard dialog box, through which you can easily set the printing options like which printer to select for printing.

Can I set the window print settings with JavaScript?

The window. print() method calls the browser's build in print support plugin to print the current DOM page. you can check the documentation, it doesn't support any argument or settings. to setup the print, you can only utilize the browser's GUI( ex. enable or disable background graphics etc.)

How do I print a page on load?

Printing the page on button clickThe command print() will invoke the default print window at the client side. This command can be used along with a button or can be used inside the body tag of the page so the print command can be executed for the full page while page is loaded to the browser.


1 Answers

<body onload="window.print()"> or window.onload = function() { window.print(); }

like image 99
Greg Avatar answered Sep 22 '22 00:09

Greg