Friday, 7 December 2012

Printing a Particular Portion of Webpage Using Javascript-Part1


Printing a Particular Portion of Webpage Using Javascript- Part1


JavaScript CODE:

    <script language="JavaScript" type="text/JavaScript">
            function doPrint() {
            bdhtml=window.document.body.innerHTML;
            sprnstr="<!--startprint-->";
            eprnstr="<!--endprint-->";
            prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
            prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
            window.document.body.innerHTML=prnhtml;
            window.print();
            }
    </script>

HTML CODE:


    <!--startprint-->
    This area will print!<!--endprint-->
    <br />
    I will not print?<input id="btnPrint" type="button" value="Print" onclick="doPrint()" />


Reference:

 http://forums.asp.net/p/1234564/2256428.aspx

No comments:

Post a Comment

Thank You for Your Comments. We will get back to you soon.

back to top