In javascript window.print(); function use to print a page. But some time we need script to print a div content. For this purpose I have coded, allow you  to print a div content with opening child page as preview and close the page after print automatically.

Code: