Last active
August 29, 2015 14:21
-
-
Save n0m4dz/c506ecbff318ce60eea9 to your computer and use it in GitHub Desktop.
This file contains 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
<html> | |
<head> | |
<script type="text/javascript"> | |
window.PrintView = function(elem) | |
{ | |
var content = document.getElementById(elem).innerHTML; | |
var mywindow = window.open('', 'my div', 'height=600,width=900'); | |
mywindow.document.write('<html><head><title>my div</title>'); | |
mywindow.document.write('</head><body >'); | |
mywindow.document.write(content); | |
mywindow.document.write('</body></html>'); | |
mywindow.document.close(); // necessary for IE >= 10 | |
mywindow.focus(); // necessary for IE >= 10 | |
mywindow.print(); | |
mywindow.close(); | |
return true; | |
}; | |
</script> | |
</head> | |
<body> | |
<div id="printDiv"> | |
Print this one. | |
</div> | |
<div> | |
not print it | |
</div> | |
<input type="button" value="Print Div" onclick="PrintView('printDiv')" /> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment