Edit in GitHubLog an issue

navigator.clipboard

See: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard

Clipboard()

Creates an instance of Clipboard.

Note: Clipboard access is not supported for 3P plugins with manifest version upto 4. Valid manifest entry required from manifest version 5.;

setContent(data)

Set data to clipboard. Note: This is a non-standard API.

Returns: Promise

ParamTypeDescription
data
object
The data to store in the clipboard. The object keys are the mime types, so for text, use text/plain as a key.

Example

Copied to your clipboard
navigator.clipboard.setContent({"text/plain": "Hello!"});

getContent()

Get data from clipboard. Note: This is a non-standard API.

Returns: Promise
Example

Copied to your clipboard
navigator.clipboard.getContent();

write(data)

Write data to clipboard. This can be used to implement cut and copy functionality.

Returns: Promise
See: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/write
Since: v6.0

ParamTypeDescription
data
object
The data to set.

Example

Copied to your clipboard
navigator.clipboard.write({"text/plain": "Hello!"});

writeText(text)

Write text to clipboard. This can be used to implement cut and copy text functionality.

Returns: Promise
See: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText
Since: v6.0

ParamTypeDescription
text
string | object
text string to set or an object of the form {"text/plain": "text to set"}. Note that the object format will be deprecated and shouldn't be used.

Example

Copied to your clipboard
navigator.clipboard.writeText("Hello!");

read()

Read data from clipboard.

Returns: Promise
See: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/read
Since: v6.0
Example

Copied to your clipboard
navigator.clipboard.read();

readText()

Read text from clipboard.

Returns: Promise
See: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/readText
Since: v6.0
Example

Copied to your clipboard
navigator.clipboard.readText();

clearContent()

Clear clipboard content. Note: Nonstandard: This method is non-standard.

Returns: Promise
Since: v6.0
Example

Copied to your clipboard
navigator.clipboard.clearContent();
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell or share my personal information
  • AdChoices
Copyright © 2024 Adobe. All rights reserved.