Advertisement
Guest User

Untitled

a guest
Jul 10th, 2014
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. <script>
  2. function Print(divID) {
  3. //Get the HTML of div
  4. var divElements = document.getElementById(divID).innerHTML;
  5. //Get the HTML of whole page
  6. var oldPage = document.body.innerHTML;
  7.  
  8. //Reset the page's HTML with div's HTML only
  9. document.body.innerHTML =
  10. "<html><head><title></title></head><body>" +
  11. divElements + "</body>";
  12.  
  13. //Print Page
  14. window.print();
  15.  
  16. //Restore orignal HTML
  17. document.body.innerHTML = oldPage;
  18.  
  19.  
  20. }
  21. </script>
  22.  
  23. <input type="button" value="Print" onclick="javascript:Print('print')" />
  24.  
  25. <div id="print">
  26. Content to be printed
  27. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement