JavaScript/Clipboard

Text can be copied to the clipboard in JavaScript using the  method. However, to prevent unsolicited copying to clipboard, web browsers only allow it in response to a click or tap by the user.

In the following demonstration, a time stamp is generated, inserted into the text area, and then copied to the clipboard.