CodeLab
Tutorials For Everyone
Run
<!DOCTYPE html> <html> <head> <title>JavaScript window.print() Method Tutorial - TutsInsider</title> <style> .main{ padding: 10px; } .main-heading{ background: #333333; color: #ffffff; padding: 20px; } .main-paragraph{ margin-top: -20px; padding: 20px; box-shadow: inset 0 0 3px 0 #2a73cc; } .main-button{ padding: 5px 10px; border: none; border-radius: 5px; background: #333333; color: #ffffff; box-shadow: 0 0 3px 0 #333333; cursor: pointer; } </style> </head> <body> <div class="main"> <h2 class="main-heading">What is JavaScript window.print() Method?</h2> <div class="main-paragraph">The JavaScript window.print() method is used to print the content of the current window. Normally JavaScript does not have any methods or functions to get the print of HTML content, but this method is an exception.</p> <button onclick="window.print()" class="main-button">Print this page</button> </div> </body> </html>