Class ClipboardAccess
Methods
StaticreadText
Uses
navigator.clipboardif available to read text from the clipboard.Note: Always returns
undefinedwhennavigator.clipboardis not available or the clipboard contains the empty string.Parameters
OptionalactiveWindow: WindowOptional active current window.
Returns Promise<string>
The current clipboard text or undefined.
StaticwriteText
Uses
navigator.clipboardif available then falls back todocument.execCommand('copy')if available to copy the given text to the clipboard.Parameters
- text: string
Text to copy to the browser clipboard.
OptionalactiveWindow: WindowOptional active current window.
Returns Promise<boolean>
Copy successful.
- text: string
Provides access to the Clipboard API for reading / writing text strings. This requires a secure context.
Note:
writeTextwill attempt to use the olderexecCommandif available whennavigator.clipboardis not available.