Last active
January 8, 2019 12:02
-
-
Save gbrian/ada40bdb3609f654d24e8e530fa30864 to your computer and use it in GitHub Desktop.
WebPage Screenshot using html2canvas
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
var src = document.createElement("script"); | |
src.setAttribute("type", "text/javascript"); | |
src.setAttribute("src", "https://html2canvas.hertzen.com/dist/html2canvas.min.js"); | |
document.head.append(src); | |
var takeScreenShot = function() { | |
html2canvas(document.body) | |
.then(canvas => { | |
document.body.appendChild(canvas); | |
var data = canvas.toDataURL(); | |
var link=document.createElement("a"); | |
link.href=data; //function blocks CORS | |
link.download = 'screenshot.jpg'; | |
link.click(); | |
link.remove(); | |
canvas.remove(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment