Created
August 22, 2013 11:00
-
-
Save kmlprtsng/6305834 to your computer and use it in GitHub Desktop.
Print contents of a div tag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //<a href="javascript:void(0)" onclick="PrintElem('.panel-div')" class="btn">Print Div</a> | |
| function PrintElem(elem) | |
| { | |
| PrintPopup($(elem).html()); | |
| } | |
| function PrintPopup(data) | |
| { | |
| //Windows title in window.open itches the IE the wrong way. | |
| var mywindow = window.open('', '', 'height=600,width=600'); | |
| mywindow.document.write('<html><head><title>Page Title</title>'); | |
| /*optional stylesheet*/mywindow.document.write('<link rel="stylesheet" href="style.css" type="text/css" />'); | |
| mywindow.document.write('</head><body >'); | |
| mywindow.document.write(data); | |
| mywindow.document.write('</body></html>'); | |
| mywindow.document.close(); | |
| mywindow.focus(); | |
| mywindow.print(); | |
| mywindow.close(); | |
| return true; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment