InterviewHubPRO
Section Overview
Q217

Question 217 of 521

Part 4: Prototypes, Object Methods & Event Loop (174 - 253)

42%
JavaScript Internals (521 Qs)•Part 4: Prototypes, Object Methods & Event Loop (174 - 253)

How do you print the contents of web page

The window object provides a print() method which is used to print the contents of the current window. It opens a Print dialog box which lets you choose between various printing options. Let's see the usage of print method in an example,

html
  <input type="button" value="Print" onclick="window.print()" />

Note: In most browsers, it will block while the print dialog is open.