Print part of a webpage with Javascript

PrintForm = function (strid) {
    var prtContent = document.getElementById(strid);
    var WinPrint = window.open('', '', 'letf=0,top=0,width=480,height=400,toolbar=0,scrollbars=0,status=0');
    WinPrint.document.write(prtContent.innerHTML);
    WinPrint.document.close();
    WinPrint.focus();
    WinPrint.print();
    WinPrint.close();
    prtContent.innerHTML = strOldOne;
}

Here’s the webpage, the printable area must be inside a div:

<div id="divPrint">
SAMPLE CONTENT
</div>
<input id="btnPrintBottom" type="button" value="Print" onclick="PrintForm('divPrint')" />



No Comments


You can leave the first : )



Leave a Reply

Your email address will not be published. Required fields are marked *