
- Javascript Basics Tutorial
- Javascript - Home
- Javascript - Overview
- Javascript - Syntax
- Javascript - Enabling
- Javascript - Placement
- Javascript - Variables
- Javascript - Operators
- Javascript - If...Else
- Javascript - Switch Case
- Javascript - While Loop
- Javascript - For Loop
- Javascript - For...in
- Javascript - Loop Control
- Javascript - Functions
- Javascript - Events
- Javascript - Cookies
- Javascript - Page Redirect
- Javascript - Dialog Boxes
- Javascript - Void Keyword
- Javascript - Page Printing
- JavaScript Objects
- Javascript - Objects
- Javascript - Number
- Javascript - Boolean
- Javascript - Strings
- Javascript - Arrays
- Javascript - Date
- Javascript - Math
- Javascript - RegExp
- Javascript - HTML DOM
- JavaScript Advanced
- Javascript - Error Handling
- Javascript - Validations
- Javascript - Animation
- Javascript - Multimedia
- Javascript - Debugging
- Javascript - Image Map
- Javascript - Browsers
- JavaScript Useful Resources
- Javascript - Questions And Answers
- Javascript - Quick Guide
- Javascript - Functions
- Javascript - Resources
How to use “window.print()” function to print a page?
To print a page in JavaScript, use the window.print() method. It opens up the standard dialog box, through which you can easily set the printing options like which printer to select for printing.
Example
You can try to run the following code to learn how to print a page −
<!DOCTYPE html> <html> <body> <button onclick="display()">Click to Print</button> <script> function display() { window.print(); } </script> </body> </html>
- Related Articles
- How to print a page using JavaScript?
- How to add a button to print an HTML page?
- How to print current date and time in a JSP page?
- How to use JavaScript to redirect an HTML page?
- How to use JavaScript to set cookies for a specific page only?
- How to use title tag in HTML Page?
- How to use href attribute in HTML Page?
- How to use floating image in HTML page?
- How to use Meta Tag to redirect an HTML page?
- How to use an animated image in HTML page?
- How to use Google Fonts on your web page?
- How to Use Meta Refresh Redirects for Page Redirects?
- How do we use function literal to define a function in JavaScript?
- How to use unlimited arguments in a JavaScript function?
- How to use multiple versions of jQuery on the same page?

Advertisements