Last active
January 27, 2021 09:18
-
-
Save CreatiCoding/8e8bc93399b8f78442036ae74660c537 to your computer and use it in GitHub Desktop.
[javascript] Div to html in chrome
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 printElement(ele, w = 800, h = 400){ | |
var divContents = document.querySelector(ele).innerHTML; | |
var printWindow = window.open('', '', `height=${h},width=${w}`); | |
printWindow.document.write('<html><head><title>NoName</title>'); | |
printWindow.document.write('</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