I have the following function to copy to the clipboard:
function getScreenShot(target){
var src = document.getElementById(target);
html2canvas(src).then(function(canvas) {
//document.src.appendChild(canvas);
canvas.toBlob(function(blob) {
navigator.clipboard
.write([
new ClipboardItem(
Object.defineProperty({}, blob.type, {
value: blob,
enumerable: true
})
)
])
.then(function() {
// do something
});
});
}
This works only on my localhost. When I run it on the server, the content doesn't get copied. I read that it has to do with security issue. How do I solve it?