ES6 - Page Printing

Many times you would like to place a button on your webpage 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 webpage when executed. You can call this function directly using the onclick event as shown in the following example.


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

The following output is displayed on successful execution of the above code.

page printing