Tuesday, 18 September 2012

Print A Div using Javascript



<html>
  <head>
     <script type="text/javascript">  
        function  PrintContentDiv() {  
           var divPrint = document.getElementById('divContent');
           var popupWin = window.open('', '_blank', 'width=300,height=300');
           popupWin.document.open();
           popupWin.document.write('<html><body onload="window.print()">' +  divPrint.innerHTML + '</html>');
            popupWin.document.close();
                }
     </script>
   </head>
        <body >
             
            <div id="divContent" >
               <div style="width:300px;height:500px;">
                <strong> Div Print on anchor click </strong>
                </div>
            </div>
            <div>
                <a href="javascript:void(0)" onclick="PrintContentDiv();"><img src="images/print-icon.png" /><br />Print<br />Item</a>
            </div>
        </body>
</html>

1 comment:

  1. I revealed a lot of attractive stuffs contained by your blog particularly its conversation. This is my first occasion I visit here. Well, this is a very valuable post. Thanks for the information you provided. It would be great if got more post like this. I appreciate it. BY - Need PHP Developer

    ReplyDelete