html print div print contents of div

The solution for “html print div print contents of div” can be found here. The following code will assist you in solving the problem.

function PrintElem(elem)
{
var mywindow = window.open(”, ‘PRINT’, ‘height=400,width=600’);

mywindow.document.write(‘‘ + document.title + ‘‘);
mywindow.document.write(‘‘);
mywindow.document.write(‘

‘ + document.title + ‘

‘);
mywindow.document.write(document.getElementById(elem).innerHTML);
mywindow.document.write(‘‘);

mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10*/

mywindow.print();
mywindow.close();

return true;
}function printDiv(divName){
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;

document.body.innerHTML = printContents;

window.print();

document.body.innerHTML = originalContents;

}

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in