"clipboard-read" permission of the Permissions API must be granted before
you can read data from the clipboard.
var promise = navigator.clipboard.readText()
Promise that resolves with a
DOMString containing the
textual contents of the clipboard. Returns an empty string if the clipboard is empty,
does not contain text, or does not include a textual representation among the
DataTransfer objects representing the clipboard's contents.
This example retrieves the textual contents of the clipboard and inserts the returned text into an element's contents.
navigator.clipboard.readText().then( clipText => document.getElementById("outbox").innerText = clipText);
|Clipboard API and events |
BCD tables only load in the browser