Javascript Copy To Clipboard

This script is pretty self explanatory. Pass a string to the copyToClipboard function and it will be placed into the clipboard so you can paste it into other programs.

The Script And An Example

I've put the script into the text area below to make it easy to get. Just click the 'Copy To Clipboard' button and the contents of the text area below will be sent to the clipboard.


The code

The code for the example above looks like...

<textarea id='testText'>#COPYTOCLIPBOARD CODE#</textarea><br> <button onclick='copyToClipboard(document.getElementById('testText').value);'>

Permissions

Mozilla based browsers will ask the user for permission before allowing this script to access the clipboard.

Comments

If you've got any questions or feedback about this article please post them in the Dynamic Tools Javascript Forum.