Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy to clipboard in JavaScript

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.

like image 518
Teifion Avatar asked Dec 13 '22 05:12

Teifion


2 Answers

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.

like image 122
rejj Avatar answered Dec 15 '22 20:12

rejj


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.

like image 27
Martijn Laarman Avatar answered Dec 15 '22 20:12

Martijn Laarman