Wednesday 28 August 2013

Javascript function to print the selected Div Tag content

Please find the javascript (no JQuery) function below to print the selected content below;
// To print selected portion of HTML content
function printDivContents(divId) {    
 var divToPrint = document.getElementById(divId);
 var popupWin = window.open('', '_blank', 'width=500,height=500,scrollbars=yes');
 popupWin.document.open();
 popupWin.document.write('< html>< body onload="window.print()">' + divToPrint.innerHTML + '');
 popupWin.document.close();
}

No comments:

Post a Comment

Please post any queries and comments here.