Print Page and then Re-Direct

[Total: 0    Average: 0/5]

This shows how to print a page and then redirect the user.

Head Code:

<script type=text/javascript> 
var NEW_LOC = "http://www.js-examples.com/"; 
function goNow() { document.location=NEW_LOC; } 
function printPage() { 
  if (confirm("Ok To Print Page?")) {
    window.print();
  }
  // The redirection occurs even if the page is not printed.
  // If you want to do the redirection only if the page is
  // printed, insert the following statement into the above
  // if block denoted by { and }
  goNow();
} 
</script> 

Body Code:

<!--
The call to printPage could have been inside the body tag or
inside a javascript section: printPage();
-->
<a href="javascript:printPage()">Print This Page</a>

Times Viewed: 11

Leave a Reply

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