Tuesday, July 31, 2012

How to Insert page break during printing


This code is helpful when you want insert page breaks between the page. You have to divide your content in divs.

<script language="javascript" type="text/javascript">
    function PrintPageBreakAfter( ){
              divs = document.getElementsByTagName(arguments[0]); 
              for (var i=0; i < divs.length-1; i++ ) { 
                     div = divs[i];
                     if(div.id!=''){
                            div.style.pageBreakAfter = (arguments[1]) ? "always":"";
                      }
           }
window.print(); 

}
    </script>


<body onload="JavaScript:togglePageBreakAfter('DIV', true, true);" topmargin="0">


<div id="div1">
   Content
</div>


<div id="div2">
    Content
</div>
free web site traffic and promotion

No comments:

Post a Comment