How to Print from JavaScript HTML using window.print


Ever came across a need where you want to print the HTML form or page. This is possible using the JavaScript window.print() function. You can use this code with any control (like Button) and even any event (like onclick). This will simply bring up the printer options from your machine and then you can follow the normal procedure of printing.

Note - A printer must be configured on your machine.

window.print();

This will not directly print the page, similar to the way you do it on your machine. The printer options window will show and you can make adjustments and settings before actually printing the contents.



















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap