views:

412

answers:

1

I have a textbox with an 'Add to clipboard' button next to it. Whenever the copy to clipboard button is pressed, I want the contents of the clipboard to get copied to the clipboard, and work in a cross browser way across Internet Explorer, Firefox, Chrome, Opera, etc. I can use jQuery or plain JavaScript.

How can this be done?

+1  A: 

Sounds like the jQuery clipboard plugin might do the job well. You can use the selector notation with it too, ot the utility $.copy

EDIT:

ZeroClipboard is another choice and this does appear to work well (tested in Firefox 3.5, IE 6 and Chrome)

Russ Cam
The jQuery one seems not to have been updated to cope with the new security model in Flash 10 (following a load of annoying clipboard-corrupting attacks). You pretty much have to let the Flash interface take the click now before you can set clipboard; that's what ZeroClipboard does.
bobince
@bobince - thanks for explaining the difference
Russ Cam