Created
December 29, 2020 22:29
-
-
Save MarkMYoung/4b215514cc5c324c18c78ff45c68fee5 to your computer and use it in GitHub Desktop.
Print a target `div` of a web page.
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 printDiv( divId ) | |
{ | |
let divContents = document.getElementById( divId ).innerHTML; | |
let printWindow = window.open( '', '', 'height=200,width=400' ); | |
printWindow.document.write( '<html><head><title>Print DIV Content</title></head><body>' ); | |
printWindow.document.write( divContents ); | |
printWindow.document.write( '</body></html>' ); | |
printWindow.document.close(); | |
printWindow.print(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment