1

I have a grid that will be containing many columns and data. Now user wants the copy to clipboard button that will allow user to copy data.

How can we achieve Copy to Clipboard functionality without using flash?

Thanks!

user3463768
  • 163
  • 1
  • 2
  • 15
  • 2
    possible duplicate of [How to copy to the clipboard in JavaScript?](http://stackoverflow.com/questions/400212/how-to-copy-to-the-clipboard-in-javascript) – aelor Apr 14 '14 at 05:26
  • Relevant similar post: [HTML5 alternative to flash-based ZeroClipboard for safe copying of data to clipboard?](http://stackoverflow.com/questions/10729570/html5-alternative-to-flash-based-zeroclipboard-for-safe-copying-of-data-to-clipb) – jfriend00 Apr 14 '14 at 05:29
  • I already had a look on all links..Please do let me know if you know anything that we can achieve using Pure Javascript and Jquery. – user3463768 Apr 14 '14 at 10:47
  • @user3463768 https://hacks.mozilla.org/2015/09/flash-free-clipboard-for-the-web/ simple html5 way of coping text to clipboard using `document.execCommand('copy')` – Samar Panda Oct 02 '15 at 16:36
  • @SamarPanda: Given that that was in **IE8**, I'm surprised I hadn't gotten soundly downvoted on my (now-deleted) answer saying you couldn't. Thank you for your comment correcting me. – T.J. Crowder Oct 02 '15 at 16:42

1 Answers1

2

There's a new API called document.execCommand() that lets you do copy and cut text to clipboard. It's already supported on most of the browsers, expect Safari.

If you want to learn more about it, I recommend reading Google's Cut and Copy Commands - HTML5 Rocks and Mozilla's Flash-Free Clipboard for the Web guides.

You also might want to check clipboard.js too. It's a super easy library to work with that.

T.J. Crowder
  • 879,024
  • 165
  • 1,615
  • 1,639
Zeno Rocha
  • 2,757
  • 1
  • 20
  • 27