Monday, March 25, 2013

Copy to Clipboard

Copying something to the clipboard was always something I found interesting, but never had to implement it until now.

There are various ways to accomplish this, however the issue is getting it to work on the various browsers and operating systems.

- Using Flash (.swf) (problems with flash versions)
- Using window.clipboardData.setData('Text', 'text to copy'); (only works with IE)
- Other options and plugins ( (deprecated)
- Using a dialog window with the text pre-selected, so that the user only needs to CTRL+C

function copyToClipboard (text) {
  window.prompt ("Copy to clipboard: Ctrl+C, Enter", text);

Stack Overflow post,

Extended clipboard ways post,

No comments:

Post a Comment