Thanks to visit codestin.com
Credit goes to www.tutorialspoint.com

Pop Up Print Dialog Box Using JavaScript



To pop-up a print dialog box using JavaScript, use the print() method. With the dialog box, you can easily set the printing options like which printer to select for printing.

This is the dialog box −

Example

You can try to run the following code to learn how to print a page −

Live Demo

<!DOCTYPE html>
<html>
   <body>
      <button onclick="display()">Click to Print</button>
      <script>
         function display() {
            window.print();
         }
      </script>
   </body>
</html>
Updated on: 2020-06-17T06:09:24+05:30

4K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements