Is there anyway to automatically run javascript:window.print()
when the page finishes loading?
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.
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.)
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.
<body onload="window.print()">
or window.onload = function() { window.print(); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With