1

I am looking for a non-plugin "copy to clipboard" function written in jQuery or JavaScript.

Basically, I just want to click on an a link and pop the HREF value into the clipboard.

Is that possible with jQuery / JavaScript?

Lightness Races in Orbit
  • 369,052
  • 73
  • 620
  • 1,021
Evik James
  • 10,095
  • 17
  • 68
  • 119
  • God, I hope not! Last thing I want is arbitrary websites messing around with _my_ clipboard. – Lightness Races in Orbit Sep 16 '11 at 20:35
  • 1
    Possible duplicate: http://stackoverflow.com/questions/1539641/copy-text-to-the-clients-clipboard-using-jquery or http://stackoverflow.com/questions/400212/how-to-copy-to-clipboard-in-javascript – Beez Sep 16 '11 at 20:35
  • I was about to copy in my (IE only) code for doing this, but I found this StackOverflow link in my comment :-) http://stackoverflow.com/questions/400212/how-to-copy-to-clipboard-in-javascript – Vivian River Sep 16 '11 at 20:47

3 Answers3

2

it is possible with : http://code.google.com/p/zeroclipboard/

its from google and its via flash and js

pretty simple implementation

Royi Namir
  • 138,711
  • 129
  • 435
  • 755
  • In mathematics, we like to say that a method is a trick (hack) that you can use more than once :-) – Vivian River Sep 16 '11 at 20:48
  • Doesn't this open the exact security hole that was closed by browsers not allowing "copy to clipboard" operations? If so then see comment 1 on op. – James Sep 16 '11 at 21:19
1

That is not possible with straight up javascript (in most broswers)

You might need some flash backend to do the copying.

Naftali
  • 142,114
  • 39
  • 237
  • 299
1

it's not possible due to browser's restrictions, for security reasons I believe.

I ended up using zeroClipboard, a light and practical flash plugin.

roselan
  • 3,733
  • 1
  • 18
  • 20