Automatically start printing html page using javascript

Is there a way to automatically run javascript:window.print() when the page loads complete?

+41
javascript html printing
Oct 27 '08 at 22:16
source share
3 answers

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

+85
Oct 27 '08 at 22:18
source share

The following code should be placed at the end of your HTML file, so that after loading the content, a script will be executed and the window will be printed.

 <script type="text/javascript"> <!-- window.print(); //--> </script> 
+12
May 6 '12 at
source share

Use this script

  <script type="text/javascript"> window.onload = function() { window.print(); } </script> 
+2
Aug 23 '16 at 12:07 on
source share



All Articles