Copy the text selection to Clipboard, using Javascript
CommentsFew days ago, Firefox announced the support to document.execCommand("copy")
in the upcoming version 41.0 (currently in Beta). This change makes a step forward towards a Flash-free world (fallbacks are Flash based). Copying text selection to Clipboard is now available on all modern browsers, except Safari.
How it works
The execCommand("copy")
API is only available during a user-triggered callback (ie. a click). When triggered, it copies the current selection to the clipboard. Using is is very straightforward and just requires a couple of lines of code.
Browsers support
To keep it simple, most modern browers are supported, except Safari. It’s actually an huge lack, we hope will get fixed soon.
Chrome | > 43.0.2356 |
Firefox | >= 41.0 |
Opera | >= 30 (release notes) |
IE | >= 9 (allows it to be called at any time, but prompts a confirmation dialog) |
Safari | Not supported |
For more details, please check out caniuse.com.
You may also be interested in ...
- Chrome 54 introduces BroadcastChannel API and Spreaker is already using it
- Chrome changes "HTTPS with mixed content" icon and add Security tab to DevTools
- Who are we developing for?
- New Chrome security policy: powerful features will be removed on insecure origins
- Chrome Android 44+ introduces a new "related apps" banner
Upcoming conferences
I will join the following conferences. Reach me out on Twitter if you
wanna meet:
Incontro DevOps 2020 | Virtual | 22 October 2020 |
---|