Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \This is the original that loads the contents of the first .printableArea.
- \Changing the code to [1] instead of [0] gives the contents of the second .printableArea
- <input type="button" align="centre" onclick="printDiv('printableArea')"
- value="Print Page" />
- <script>
- function printDiv(divName) {
- var printContents = document.getElementsByClassName(divName)
- [0].innerHTML;
- var originalContents = document.body.innerHTML;
- document.body.innerHTML = printContents;
- window.print();
- document.body.innerHTML = originalContents;
- }
- </script>
- \This also yields a result if I change to using an id instead of class.
- <input type="button" align="centre" onclick="printDiv('printableArea')"
- value="Print Page" />
- <script>
- function printDiv(divName) {
- var printContents = document.getElementById(divName).innerHTML;
- var originalContents = document.body.innerHTML;
- document.body.innerHTML = printContents;
- window.print();
- document.body.innerHTML = originalContents;
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement