I'm trying to take a screenshot and save it in a specific folder in my local computer with an onclick in a button, using HTML and JavaScript (or JQuery).
Asked
Active
Viewed 451 times
0
-
You probably need to learn about canvas – Fritzdultimate Aug 07 '20 at 21:28
-
Does this answer your question? [Using HTML5/Canvas/JavaScript to take in-browser screenshots](https://stackoverflow.com/questions/4912092/using-html5-canvas-javascript-to-take-in-browser-screenshots) – dibery Aug 08 '20 at 08:10
1 Answers
0
There's no way to save DOM elements as an image (unless you just use Firefox or something), but you can convert the DOM elements into canvas and save the image from there.
See http://html2canvas.hertzen.com/
Then use canvas.toDataURL()
to save the image.

Yikuan Sun
- 1
- 3
-
-
With this script the screenshot is saved in Dowbload folder, but I need to change it, I need to save tis screenshot in C:/screens/ html2canvas(document.body, { onrendered (canvas) { var link = document.getElementById('dwnld'); var image = canvas.toDataURL(); link.href = image; link.download = 'sc.png'; } }); – Manuel Garcia Aug 07 '20 at 22:24
-
@ManuelGarcia it's actually impossible for JavaScript to set the Download folder (due to security reasons) and it's the user's job to change the folder. On Google Chrome, you can head to chrome://settings and head to the "Downloads" section. – Yikuan Sun Aug 08 '20 at 23:22