admin管理员组文章数量:1403343
I already use html2canvas.js to take a screenshot of a specific div, now I wonder if I could use js to copy the canvas
element as an image to clipboard, then user can just click to have an image of what they want on their clipboard, all they need to do is just paste it.
Codepen Demo
I already use html2canvas.js to take a screenshot of a specific div, now I wonder if I could use js to copy the canvas
element as an image to clipboard, then user can just click to have an image of what they want on their clipboard, all they need to do is just paste it.
Codepen Demo
Share Improve this question asked Oct 27, 2016 at 7:03 AlessiaAlessia 96911 silver badges16 bronze badges1 Answer
Reset to default 6It work only on https or localhost:
function getScreenShot(Src){
let src = document.getElementById(Src);
html2canvas(src).then(function(canvas) {
document.getElementById("explain-scr").appendChild(canvas);
canvas.toBlob(function(blob) {
navigator.clipboard
.write([
new ClipboardItem(
Object.defineProperty({}, blob.type, {
value: blob,
enumerable: true
})
)
])
.then(function() {
// do something
});
});
});
}
本文标签: html2canvasHow To Copy Canvas As Image To Clipboard Using Javascript ProgrammaticallyStack Overflow
版权声明:本文标题:html2canvas - How To Copy Canvas As Image To Clipboard Using Javascript Programmatically - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744409460a2604876.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论