Page Printing.

Page Printing.

(30 Days Of JavaScript.)

ยท

1 min read

Many times you would like to place a button on your web page to print the content of that web page via an actual printer. JavaScript helps you implement this functionality using the print function of the window object.

The JavaScript Print

function window.print() prints the current web page when executed. You can call this function directly using the onclick event as shown in the following example:

<html>
  <body>
     <form>
<input type = "button" value = "Print" onclick = "window.print()" />
</form>
</body>
</html>