views:

321

answers:

1

Is it possible to copy an image to the clipboard in javascript? I know how to copy text, but can you copy images?

Is it a security limitation?

A: 

No, you can't copy images to the clipboard. Copying anything to the clipboard is a security limitation of every browser, but you may able to copy text to the clipboard in IE if they have the proper security settings. Here Mozilla lists some of the problems caused by programmatic access to the clipboard.

Josh Stodola
@hobodave Then you must be browsing with IE, and you have changed your settings to allow it. Either that or you have a special FireFox add-on that allows it.
Josh Stodola
@hobodave visit github with Firefox and report back about what's in your clipboard.
Pointy
@Josh: Apologies, you are correct. There are ways to do it in FF though apparently: http://www.febooti.com/support/website-help/website-javascript-copy-clipboard.html . The functionality on github is actually achieved using Flash; I had assumed :-D it was javascript.
hobodave
I should say that I've seen Flash and Java Applet implementations that assist with copying to the clipboard (using Javascript to invoke them). Both options, however, are not suited for any production environment, IMO.
Josh Stodola
@Pointy: It works.
hobodave
thanks, just wanted to establish this in stone so people don't have to search for hours with false hope :)
viatropos