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
object
The text to set. Note, currently this will fail unless this is an object of the form {"text/plain": "text to set"}. This will be fixed in a future release.

Example

Copied to your clipboard
navigator.clipboard.writeText({"text/plain": "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.