I am using this directive to implement copy to clipboard functionality. But this doesnt work with safari. I tried to find an alternative using this. But this also doesnt have support for safari. I found in the explanation that "copy/cut operations with execCommand aren't supported on Safari yet (including mobile)". So I wanted to crosscheck is this functionality actually not possible to be supported on safari. Any leads would help. Thanks in advance
Asked
Active
Viewed 671 times
1 Answers
0
Copy to clipboard from JavaScript is not supported in Safari, as the ClipboardEvent constructor is not implemented in Safari...
Most code relies on something similar to the following:
var copyEvent = new ClipboardEvent('copy',
{ dataType: 'text/plain', data: 'Safari Test' } );
document.dispatchEvent(copyEvent);
You might be able to get it working in Safari using Selection
, hidden elements and script generated events, I have't looked at that approach.

Greg
- 36
- 3
-
I couldnt get this working. Anyway I tried opening github on safari. It turns out that copy git link also doesnt work on safari. So I dont know if it is worth it to sweat so much upon it. – Sahil Sharma May 10 '16 at 06:15