Copies text to a site visitor's clipboard.
The copyToClipboard()
method copies the specified text to a site visitor's clipboard.
If a site visitor's browser doesn't support copying text to the clipboard
programmatically, a modal popup that allows copying will be displayed.
For example, when calling copyToClipboard()
from a Firefox or Edge browser,
a site visitor will see something similar to the popup shown below.
The Promise returned by copyToClipboard()
resolves when the
specified text is copied to clipboard or the modal popup is closed.
The Promise is rejected if a null
value is passed as the toCopy
parameter
or if a site visitor's browser blocks the modal popup from opening.
The text to copy.