OnClick image, copy text to clipboard?

by 9 replies
11
Hi guys. I want to be able to copy text to clipboard when an image is clicked.

It's for a coupon code. I've seen this done on sites before, you click the image and it copies the coupon code to clipboard. I've also seen examples where a little bit of text displays "code copied to clipboard"

I've been searching around online and can't find anything that works...

Any ideas?

Cheers
#programming #clipboard #copy #image #onclick #text
  • I think you're looking for this ZeroClipboard v2.x
  • It's just a bit of javascript. You add a click event to the image, and in the click event you have the coupon code copied to the clipboard.
    • [2] replies

    • Ye... but I don't know how to do that
    • Actually, if you want a cross-browser solution, pure JavaScript won't hack it. Most people use Flash or a third-party library (such as the one AdWordsUzmani mentioned) to get this functionality.
      • [2] replies
  • Hello thedog, if You wanna learn how javascript works You can check it out here JavaScript | Codecademy and find out everything about it and You can learn it easy.
  • You may want to consider this rather elegant solution: Copy to Clipboard LMCButton

    Please let me know if you go in this direction; I actually have some enhancements which I commissioned and then gave back to the original author, but he never posted them on that site. You can have them for free.

Next Topics on Trending Feed

  • 11

    Hi guys. I want to be able to copy text to clipboard when an image is clicked. It's for a coupon code. I've seen this done on sites before, you click the image and it copies the coupon code to clipboard. I've also seen examples where a little bit of text displays "code copied to clipboard"