4

Is there a way at all of altering the clipboard of the user via JavaScript?

I want it that they click a given point on a map, and it adds the coordinates of the position to their clipboard.

I do however assume that this is not possible for JavaScript to achieve.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Teifion
  • 108,121
  • 75
  • 161
  • 195
  • Yes it is possible and without any library at all. Take a look at this answer - https://stackoverflow.com/questions/46041831/copy-to-clipboard-with-break-line/50230647#50230647 – KeshavDulal May 08 '18 at 10:06

3 Answers3

10

You could try using the zeroclipboard library, which involves placing an invisible flash element on the page to do the actual copy of text to the clipboard.

rejj
  • 152
  • 2
2

It is in Internet Explorer, but not in other browsers although support can be hacked together in other browsers by inserting a Flash file each time you want to do a copy. Not very useful I would say, as it imposes usability drawbacks as well.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Martijn Laarman
  • 13,476
  • 44
  • 63
1

If I remember correctly it is possible in the Internet Explorer (maybe the site must be in the "trusted" zone) but not in Firefox or Opera.

Martin Thurau
  • 7,564
  • 7
  • 43
  • 80