Created
March 5, 2021 07:24
-
-
Save sabesansathananthan/112bc6b148af4ae79a51be7074a093ef to your computer and use it in GitHub Desktop.
Clipboard Operation in JavaScript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function copy() { | |
const image = await fetch('kitten.png'); | |
const text = new Blob(['Cute sleeping kitten'], {type: 'text/plain'}); | |
const item = new ClipboardItem({ | |
'text/plain': text, | |
'image/png': image | |
}); | |
await navigator.clipboard.write([item]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment