web api interface
Clipboard
Secure context
The Clipboard interface of the Clipboard API provides read and write access to the contents of the system clipboard.
This allows a web application to implement cut, copy, and paste features.
The system clipboard is exposed through the global clipboard property.
All of the Clipboard API methods operate asynchronously; they return a Promise which is resolved once the clipboard access has been completed.
The promise is rejected if clipboard access is denied.
All the methods require a secure context. Additional requirements for using the API are discussed in the Security consideration section of the API overview topic.
Instance methods
Clipboard is based on the EventTarget interface, and includes its methods.
read()- : Requests arbitrary data (such as images) from the clipboard, returning a
Promisethat resolves with an array ofClipboardItemobjects containing the clipboard’s contents.
- : Requests arbitrary data (such as images) from the clipboard, returning a
readText()- : Requests text from the system clipboard, returning a
Promisethat is fulfilled with a string containing the clipboard’s text once it’s available.
- : Requests text from the system clipboard, returning a
write()- : Writes arbitrary data to the system clipboard, returning a
Promisethat resolves when the operation completes.
- : Writes arbitrary data to the system clipboard, returning a
writeText()- : Writes text to the system clipboard, returning a
Promisethat is resolved once the text is fully copied into the clipboard.
- : Writes text to the system clipboard, returning a
Events
clipboardchangeExperimental- : Fired when the system clipboard contents are changed in any way, for example via a system copy command, or via an API method such as
writeText().
- : Fired when the system clipboard contents are changed in any way, for example via a system copy command, or via an API method such as
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.