Clipboard API
Need to read/write to the users' Clipboard?
Write permalink
await navigator.clipboard.writeText(SOME_VALUE)
navigator.clipboard.writeText(SOME_VALUE).then(() => alert("Copied!"))
Read permalink
await navigator.clipboard.readText()
navigator.clipboard.readText().then(value => alert(`Paste ${value}!`))
- If you need this in an
iframe
. Set theiframe
permissions to allow clipboard read/write navigator.clipboard
methods return aPromise
. Eitherawait
or use a callback.