Wednesday 23 November 2011

How to open print dialog box in JavaScript

How to pop-up print dialog box from html page or link or button using JavaScript.

Here is the example to print open a content of a page in another window and print them.



function CallPrint(strid)
 {
           var prtContent = document.getElementById(strid);
         var WinPrint = window.open('', '', 'letf=100,top=100,width=600,height=600,toolbar=0,scrollbars=1,status=0');
            WinPrint.document.write(prtContent.innerHTML);
            WinPrint.document.close();
            WinPrint.focus();
            WinPrint.print();
            //WinPrint.close()   
 }


 

No comments:

Post a Comment