0

Is there a simple way/function to copy a sentence to the clipboard with JavaScript (no flash or jQuery)?

The function must be supported in Chrome; others browsers don't matter.

Mia
  • 817
  • 2
  • 8
  • 13
  • 2
    Check the answers here : http://stackoverflow.com/questions/400212/how-do-i-copy-to-the-clipboard-in-javascript?page=1&tab=votes#tab-top – stark Jan 22 '16 at 19:24
  • @stark I have done that before I posted this question but the answers in there are not useful. – Mia Jan 22 '16 at 19:25
  • @Mia They are useful, especially [this answer](http://stackoverflow.com/a/30810322/283863). – Derek 朕會功夫 Jan 22 '16 at 19:27
  • @Derek朕會功夫 I need a function which only has a button like `
    Click to copy
    `, the answers on there are with textareas and all that.
    – Mia Jan 22 '16 at 19:30
  • @Mia That is because to copy text into clipboard in JavaScript, you must have an editable space. The collection of answers there explained it pretty well. See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand) for details. – Derek 朕會功夫 Jan 22 '16 at 21:48

0 Answers0