Home | All Questions | alt.html FAQ > Client-side Basic Scripting

How do I create a link that prints the current page?

This requires the use of javascript, and a browser that offers a print function as part of its object model. Its not a good idea assuming everyone has javascript enabled, so best enclose the showing of the print-page link in Javascript, and also do a check whether the browser has a print() function to use:

<script type="text/javascript">
 if (window.print) {
  document.write("<a href='#' onClick='window.print();
  return false;'>Print this Page</a>");
 }
</script>

Recommended Resources

Discussion

Related Questions