A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://developer.mozilla.org/en-US/docs/Web/API/Clipboard/readText below:

Clipboard: readText() method - Web APIs

Clipboard: readText() method

Baseline 2024

Newly available

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

The readText() method of the Clipboard interface returns a Promise which fulfills with a copy of the textual contents of the system clipboard.

Note: To read non-text contents from the clipboard, use the read() method instead. You can write text to the clipboard using writeText().

Syntax Parameters

None.

Return value

A Promise that resolves with a string 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 objects representing the clipboard's contents.

Exceptions
NotAllowedError DOMException

Thrown if the access to read the clipboard is not allowed.

NotFoundError DOMException

Thrown if the clipboard indicates that it contains data that can be represented as a text but is unable to provide a textual representation.

Security considerations

Reading from the clipboard can only be done in a secure context.

Additional security requirements are covered in the Security consideration section of the API overview topic.

Examples

This example retrieves the textual contents of the clipboard and inserts the returned text into a selected element's contents.

const destination = document.getElementById("outbox");
destinationImage.addEventListener("click", () => {
  navigator.clipboard
    .readText()
    .then((clipText) => (destination.innerText = clipText));
});
Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4