Last active
December 6, 2017 08:15
-
-
Save tovask/605607f296e10af03adcd39b260589ab to your computer and use it in GitHub Desktop.
simple javascript code to save the page as an image, using http://html2canvas.hertzen.com/ , no external script required (, designed to run from scratchpad/console)
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
var script = document.createElement('script'); | |
script.onload = function () { | |
html2canvas(document.body, { | |
allowTaint: true, | |
//taintTest: false, | |
logging: true, | |
onrendered: function(canvas) { | |
var img = canvas.toDataURL("image/png"); // window.location.href = img.replace("image/png", "image/octet-stream"); | |
var link = document.createElement("a"); | |
link.download = "page.png"; | |
link.href = img; | |
document.body.appendChild(link); | |
link.click(); | |
document.body.removeChild(link); | |
delete link; | |
} | |
}); | |
}; | |
script.src = "//html2canvas.hertzen.com/build/html2canvas.js"; | |
document.head.appendChild(script); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment