The window.print() method neither accepts parameters nor returns anything.
<button onclick="user_defined_method()">Please Press Button</button>
The description of the code is as follows:
- An HTML button is created which will call the user_define_method() on its oclick event.
- Inside the <script> tag, the function user_defined_method() is created which contains the window.print() method inside it.
It is observed from the output, that if a user presses button “Please Press Button” the print dialgoue is opened which will enable you to print the web-page.