My Computer Tips

Home | About | Categories | All Tips & Tutorials

Display Print Dialogue window using Javascript

ID: 372

Category: Vanilla Javascript

Added: 19th of March 2024

Updated On: Tutorial updated and rechecked on 6th of November 2024

Views: 498



Click here to buy Javascript books on Amazon
Affiliate Link ⓘ

To display the Print Dialogue window in your web browser using Javascript, use the window.print() function. Below are two examples, one using a standard link and another using a button.

Regular HTML link

<a href="javascript:window.print()">Print This Page</a>

Result
Print This Page

Input Type Button
<input type="button" value="Print This Page" onClick="window.print()">

Result