JS

PRINT PAGE OR SECTION IN JAVASCRIPT

<h1>TITLE</h1> <p>Content</p>   <input type="button" value="Print Page" onclick="window.print()"/>

PRINT ENTIRE PAGE

01

HTML SECTION TO BE PRINTED <div id="toprint">   <h1>Foo Bar!</h1> <p>Hello World</p> </div>

PRINT PART OF PAGE

02

JS PRINT SECTION function printpart () {   var printwin = window.open("");   printwin.document.write     (document.getElementById("toprint")     .innerHTML);   printwin.stop(); printwin.print();   printwin.close(); }

CSS ALTERNATIVE

03

CSS SPECIFY PRINT AREAS @media only print {   body { visibility: hidden; }   .printthis { visibility: visible; } }

ONLY .PRINTTHIS WILL SHOW UP IN PRINT <p>This will not be printed.</p> <div class="printthis">   <h1>This section will be printed</h1>   <div>Foo bar!</div> </div>