I am taking screenshot of webpage using html2canvas and then copy the content to clipboard using navigator.clipboard.write and ClipboardItem. This works fine on chrome
tempCanvas.toBlob(function(blob) {
navigator.clipboard
.write([
new ClipboardItem(
Object.defineProperty({}, blob.type, {
value: blob,
enumerable: true
})
)
]).then(function() {
console.log( "Copied to clipboard");
});
});
But this doesn't work on Firefox and Safari
I was trying
tempCanvas.toBlob(function(blob) {
let data = new DataTransfer();
data.items.add("image/jpeg", blob);
navigator.clipboard.write(data).then(function() {
console.log( "Copied to clipboard");
});
});
Seems not working.