Print the current page:
Click the button to print the current page.
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Print this page</button> <script> function myFunction() {//from ww w . j a v a2 s .c om window.print(); } </script> </body> </html>
The print()
method prints the contents of the current window.
The print()
method opens the Print Dialog Box, which lets the user to select preferred printing options.
window.print();