Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- function Print(divID) {
- //Get the HTML of div
- var divElements = document.getElementById(divID).innerHTML;
- //Get the HTML of whole page
- var oldPage = document.body.innerHTML;
- //Reset the page's HTML with div's HTML only
- document.body.innerHTML =
- "<html><head><title></title></head><body>" +
- divElements + "</body>";
- //Print Page
- window.print();
- //Restore orignal HTML
- document.body.innerHTML = oldPage;
- }
- </script>
- <input type="button" value="Print" onclick="javascript:Print('print')" />
- <div id="print">
- Content to be printed
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement