How can I copy text to the clipboard without flash in HTML5? How can I copy text to the clipboard without flash in HTML5? google-chrome google-chrome

How can I copy text to the clipboard without flash in HTML5?


It is not possible to do it without flash as far as I know. However, if you are using Google Chrome and you installed the Drive App(from the webstore) then you give the browser permission to use your copy and paste.

Try clicking on "right click menu" section in this article: google drive help

Basically, you need permission from the browser. If you can't, then trick the user. I once made a canvas which displayed text, and when the user dragged their mouse it would select the corresponding text in an invisible <div>, and when you press Control+C or Cmd+C you are copying the text using the native shortcut, javascript can't mimic these keys.

The best you can do with javascript is to select the text using document.createRange() and leave it to the user to press Control+C or Cmd+C.