Search code examples
mobileclipboard

Copy to Clipboard that also works on Mobile?


I'm familiar with ZeroClipboard and jquery.copy, which both use Flash. OK, so I get it, for browser security reasons, copying is disallowed and we need Flash. But this means the copying functionality does not work in mobiles (iPhone, Android) or iPad.

Is there any resource or plugin that allows a simple Copy to Clipboard functionality on both modern browsers (include IE7+) and mobile browsers?

Thanks!


Solution

  • I just wanted to offer an update, since there have been some recent developments on this front. Modern browsers, except for Safari support copying via JS, using the execCommand() api.

    Assuming you build your UI to gracefully degrade to manual copying for Safari, you could implement copy-to-clipboard on the rest of them. Presumably, Safari will include support for this eventually.

    Look at https://clipboardjs.com/ and http://www.sitepoint.com/javascript-copy-to-clipboard/ for options.

    Browsers supported, as of writing: Chrome 42+, Firefox 41+, IE 9+, Opera 29+.