Print the contents of DIV

We can simply use below java script function to print a web page or Print the contents of DIV.  Here we need to give the id of the table or div which we need to print.

Use below java script function to Print a web page or Print the contents of DIV.

function PrintPage() {
var area = document.getElementById(‘tblPrint‘);
var uniqueName = new Date();
var windowName = ‘Print’ + uniqueName.getTime();
var pwindow = window.open(“”, windowName, “scrollbars=1,menubar=1,status=0,resizable=1″);

pwindow.document.write(area.outerHTML);
pwindow.document.close();
pwindow.focus();
pwindow.print();
pwindow.close();

}

 

Leave a Reply