Created
March 5, 2021 06:04
-
-
Save sabesansathananthan/76f7c84a947bd20eece886eadf2e47f3 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
async function getClipboardContents() { | |
try { | |
const clipboardItems = await navigator.clipboard.read(); | |
for (const clipboardItem of clipboardItems) { | |
for (const type of clipboardItem.types) { | |
const blob = await clipboardItem.getType(type); | |
console.log(URL.createObjectURL(blob)); | |
} | |
} | |
} catch (err) { | |
console.error(err.name, err.message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment