Copies text to the site visitor's clipboard.
The copyToClipboard()
function copies the specified text to the site visitor's clipboard.
If the site visitor's browser does not 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
the 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 the visitor's browser blocks the modal popup from opening.
The text to copy.