The Clipboard API provides the ability to respond to clipboard commands (cut, copy, and paste) as well as to asynchronously read from and write to the system clipboard.
Note: The clipboard is a data buffer that is used for short-term, data storage and/or data transfers, this can be between documents or applications. It is usually implemented as an anonymous, temporary data buffer, sometimes called the paste buffer, that can be accessed from most or all programs within the environment via defined programming interfaces.
This snippet fetches the text from the clipboard and appends it to the first element found with the class editor. Since readText() (and read(), for that matter) returns an empty string if the clipboard isn't text, this code is safe.
Provides an interface for reading and writing text and data to or from the system clipboard. The specification refers to this as the 'Async Clipboard API'.
Represents events providing information related to modification of the clipboard, that is cut, copy, and paste events. The specification refers to this as the 'Clipboard Event API'.
9876–98The ClipboardItem constructor only accepts a blob as the item data, but not strings or Promises that resolve to strings or blobs. See bug 1014310.
9879–98The ClipboardItem constructor only accepts a blob as the item data, but not strings or Promises that resolve to strings or blobs. See bug 1014310.
87
No
8463–84The ClipboardItem constructor only accepts a blob as the item data, but not strings or Promises that resolve to strings or blobs. See bug 1014310.
13.1
9884–98The ClipboardItem constructor only accepts a blob as the item data, but not strings or Promises that resolve to strings or blobs. See bug 1014310.
9884–98The ClipboardItem constructor only accepts a blob as the item data, but not strings or Promises that resolve to strings or blobs. See bug 1014310.
No
6860–68The ClipboardItem constructor only accepts a blob as the item data, but not strings or Promises that resolve to strings or blobs. See bug 1014310.
13.4
18.014.0–18.0The ClipboardItem constructor only accepts a blob as the item data, but not strings or Promises that resolve to strings or blobs. See bug 1014310.
Clipboard_API
76
79
87
No
63
13.1
84
84
No
60
13.4
14.0
getType
76
79
87
No
63
13.1
84
84
No
60
13.4
14.0
presentationStyle
No
No
87
No
No
13.1
No
No
No
No
13.4
No
types
76
79
87
No
63
13.1
84
84
No
60
13.4
14.0
Desktop
Mobile
Chrome
Edge
Firefox
Internet Explorer
Opera
Safari
WebView Android
Chrome Android
Firefox for Android
Opera Android
Safari on IOS
Samsung Internet
ClipboardEvent
58
17
22
No
45
10.1
58
58
22
43
10.3
7.0
Clipboard_API
41
12
22
4
28
10.1
41
41
22
28
10.3
4.0
clipboardData
41
12
22
5
28
10.1
41
41
22
28
10.3
4.0
Desktop
Mobile
Chrome
Edge
Firefox
Internet Explorer
Opera
Safari
WebView Android
Chrome Android
Firefox for Android
Opera Android
Safari on IOS
Samsung Internet
Clipboard_API
66
79
63
No
53
13.1
66
66
63
47
13.4
9.0
read
86From version 86, the text/html MIME type is supported.76From version 76, the image/png MIME type is supported.66Images are not supported.
79
90Firefox only supports reading the clipboard in browser extensions, using the "clipboardRead" extension permission.
No
63
13.1
84From version 84, the image/png MIME type is supported.66Images are not supported.
86From version 86, the text/html MIME type is supported.84From version 84, the image/png MIME type is supported.66Images are not supported.
No
54
13.4
12.0
readText
66
79
NoFirefox only supports reading the clipboard in browser extensions, using the "clipboardRead" extension permission.
No
53
13.1
66
66
NoFirefox only supports reading the clipboard in browser extensions, using the "clipboardRead" extension permission.
47
13.4
9.0
write
66From version 76, the image/png MIME type is supported.
79
87Writing to the clipboard is available without permission in secure contexts and browser extensions, but only from user-initiated event callbacks. Browser extensions with the "clipboardWrite" permission can write to the clipboard at any time.63["This method accepts a DataTransfer object instead of an array of ClipboardItem objects.", "Writing to the clipboard is available without permission in secure contexts and browser extensions, but only from user-initiated event callbacks. Browser extensions with the \"clipboardWrite\" permission can write to the clipboard at any time."]
No
63
13.1
66From version 84, the image/png MIME type is supported.
66From version 84, the image/png MIME type is supported.
No
54
13.4
12.0
writeText
66
79
63Writing to the clipboard is available without permission in secure contexts and browser extensions, but only from user-initiated event callbacks. Browser extensions with the "clipboardWrite" permission can write to the clipboard at any time.
No
53
13.1Must be called within user gesture event handlers such as pointerdown or pointerup.
66
66
63Writing to the clipboard is available without permission in secure contexts and browser extensions, but only from user-initiated event callbacks. Browser extensions with the "clipboardWrite" permission can write to the clipboard at any time.
47
13.4Must be called within user gesture event handlers such as pointerdown or pointerup.