Copy Text To Clipboard
zClip
zClip is a lightweight jQuery "copy to clipboard" plugin built using the popular Zero Clipboard library. This plugin uses an invisible Adobe Flash movie that is fully.
clipboard.js
This library relies on both Selection and execCommand APIs. The second one is supported in the following browsers.
42+ ✔ | 12+ ✔ | 41+ ✔ | 9+ ✔ | 29+ ✔ | 10+ ✔ |
Although copy/cut operations with execCommand aren't supported on Safari yet (including mobile), it gracefully degrades because Selection is supported.
That means you can show a tooltip saying Copied!
when success
event is called and Press Command+C to copy
when error
event is called because the text is already selected.
References
[2] clipboard.js@TT4IT, clipboard.js — A modern approach to copy text to clipboard. No Flash. No frameworks. Just 3kb gzipped
[3] Docs@MDN, Document.execCommand()