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
  • 358,771
  • 68
  • 593
  • 989
Evik James
  • 9,645
  • 15
  • 67
  • 118
  • 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
  • 131,490
  • 121
  • 408
  • 714
  • 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 aka Neal
  • 138,754
  • 36
  • 231
  • 295
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,695
  • 1
  • 17
  • 20