Friday, 7 December 2012

Printing a Particular Portion of Webpage Using Javascript-Part2


Printing a Particular Portion of Webpage Using Javascript-Part2

 

JavaScript CODE:

    <script language="javascript" type="text/javascript">
        function printdiv(divID)
        {
          var headstr = "<html><head><title></title></head><body>";
          var footstr = "</body>";
          var newstr = document.all.item(divID).innerHTML;
          var oldstr = document.body.innerHTML;
          document.body.innerHTML = headstr+newstr+footstr;
          window.print();
          document.body.innerHTML = oldstr;
          return false;
        }
    </script>


HTML CODE:


    <input name="b_print" type="button" onclick="printdiv('divID');" value=" Print " />
    <div id="divID">
    <h1 style="color:green">
    The Div content which you want to print</h1>
    </div>


Reference:

http://forums.asp.net/t/1263912.aspx

No comments:

Post a comment

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

back to top