3 ms·
I'd love this to be native... something like $(0).screenshot() would produce a base64 string of the rendered element. Why doesn't this exist? Why do we need to
by andrethegiant 7y ago
I'd love this to be native... something like $(0).screenshot() would produce a base64 string of the rendered element. Why doesn't this exist? Why do we need to rely on browser extensions? The closest JS-based equivalent I've found is html2canvas, which doesn't work as well as advertised.
- Sephr 7y agoYou can screenshot DOM structures natively by including them in an SVG <foreignObject>, composing an SVG blob URL, rendering it in an <img> tag, and then drawing that to a <canvas>. I started a project related to this years ago but never finished it. Now that same-origin canvas taint issues have been fixed in most browsers, maybe it's time for me to work on this again. A related API that is not accessible to web content is Safari's console.screenshot() utility[1]. [1]: https://twitter.com/webkit/status/1222236427326373888 https://twitter.com/webkit/status/1222236427326373888
- mindfulplay 7y agoIt's a security landmine. IFRAMES, mixed content, downloading / rendering behaviors are all sensitive and may contain private information known only to the browser/user and not the containing webpage.
- aswan 7y agoFirefox has: https://developer.mozilla.org/en-US/docs/Tools/Taking_screenshots https://developer.mozilla.org/en-US/docs/Tools/Taking_screen...