Posted By

BFTrick on 06/02/09


Tagged


Versions (?)

Print Section


 / Published in: JavaScript
 

Add a div with the ID = 'printarea' around the target area.

Add a button to call this function.

Replace style sheet.

  1. <script type="text/javascript" language="javascript">
  2. function printSelection()
  3. {
  4. var html = '<HTML><HEAD><link href="/files/css/style.css" rel="stylesheet" type="text/css" />';
  5.  
  6. html += '</HEAD><BODY>';
  7.  
  8. var printReadyElem = document.getElementById("printarea");
  9.  
  10. html += printReadyElem.innerHTML;
  11.  
  12. html += '</BODY></html>';
  13.  
  14. var printWin = window.open("","printSpecial");
  15. printWin.document.open();
  16. printWin.document.write(html);
  17. printWin.document.close();
  18. printWin.print();
  19. printWin.close();
  20. }
  21. </script>

Report this snippet  

You need to login to post a comment.