Automatic Javascript Print Example

Back to Examples | Back to Blog

When you open this page, the print dialog window should appear automatically.

Not much magic to it, just an onload statement in the Body tag.


<head>
    <title>Print a HTML page with Javascript</title>

<script type="text/javascript" language="javascript">
<!--
  function printThisPage() {
    window.print();  
  }
  //-->
</script>


</head>
<body onload="printThisPage()">