Skip to content

Instantly share code, notes, and snippets.

@sabesansathananthan
Created March 5, 2021 06:04
Show Gist options
  • Save sabesansathananthan/76f7c84a947bd20eece886eadf2e47f3 to your computer and use it in GitHub Desktop.
Save sabesansathananthan/76f7c84a947bd20eece886eadf2e47f3 to your computer and use it in GitHub Desktop.
Clipboard Operation in JavaScript
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