The syntax of the print function is:
This simple syntax neither gets any parameters nor returns anything. It simply fires the print window.
We simply have to make a button in our HTML, and on the on-click event of that button we can directly call the window.print() function.
Then, on the web page, if we click the button, it will open up a window or dialog box, which we usually see while printing any document.
Be careful that it will print everything on the webpage. Either that web page includes images or advertisements.
In this article, we have learned how we can print the whole web page, and the benefits and consequences of doing that.