6

Is there the possbility to get the textual content of the clipboard to paste it automatically into a textarea clicking a button? Just found a method to copy data to it, but not to read data from it.

Martin Cup
  • 2,399
  • 1
  • 21
  • 32

2 Answers2

7

No, you cannot do this in javascript because it has proven to be a huge security hole.
Likewise, the developers of Greasemonkey are unlikely to add this capability for the same reasons.


You can write a Firefox add-on that does this, but I've never seen a (legit) use case.

A technique that works well for me is to have the Greasemonkey script set focus to the textarea (or input) and then I merely press CtrlV. It's super convenient and actually faster than grabbing the mouse to click a button.

Community
  • 1
  • 1
Brock Adams
  • 90,639
  • 22
  • 233
  • 295
  • 3
    -1 We are opining on what is "legitimate" so perhaps that part of the answer is not appropriate for SO. There are legitimate use cases IMO. If someone has carpal tunnel or other accessibility issues, being able to manipulate clipboard content to reduce repetitive keystrokes is a less painful way to work. Or imagine someone with no arms having to do this with a pencil in their mouth, or paste using a cam that tracks your eye movement. – Sun Sep 02 '21 at 19:21
-2

You can try to implement this using the clipboard interface.

Please check this out:

Gesugao-san
  • 59
  • 1
  • 7
  • Welcome to SO, Gesugao-san! Links are not considered an anser. Please, post a complete answer on your own, even you base your examples or documented definition from a link that you may share at the end of the answer. – juagicre Mar 28 '22 at 15:53