Created
December 12, 2019 10:47
-
-
Save narwanimonish/66fc83e6643a82e980f39ff93a21b5b3 to your computer and use it in GitHub Desktop.
How to print single elment (div) of tab in any browser in javascript
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
function PrintElem(elem) | |
{ | |
var mywindow = window.open('', 'PRINT', 'height=400,width=600'); | |
mywindow.document.write('<html><head><title>' + document.title + '</title>'); | |
mywindow.document.write('</head><body >'); | |
mywindow.document.write('<h1>' + document.title + '</h1>'); | |
mywindow.document.write(document.getElementById(elem).innerHTML); | |
mywindow.document.write('</body></html>'); | |
mywindow.document.close(); // necessary for IE >= 10 | |
mywindow.focus(); // necessary for IE >= 10*/ | |
mywindow.print(); | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment