Copy to clipboard that also works on Mobile?

I am familiar with ZeroClipboard and jquery.copy that use Flash. Ok, so I understand that for browser security reasons, copying is forbidden and we need Flash. But this means that the copy function does not work on mobile phones (iPhone, Android) or iPad.

Is there any resource or plugin that allows you to use simple copy to clipboard functions both in modern browsers (including IE7 +) and in mobile browsers?

Thanks!

+8
clipboard mobile
source share
2 answers

I just wanted to offer an update, as there were some recent events on this front. Modern browsers, in addition to Safari, support copying through JS using the execCommand () api.

Assuming that you create your own user-friendly interface for degradation for manual copying for Safari, you can implement copying to the buffer for the rest. Presumably, Safari will include support for this in the long run.

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

Browsers are supported starting from writing: Chrome 42+, Firefox 41+, IE 9+, Opera 29+.

+2
source share

It is impossible to do this without using a flash. I would just keep it simple and let your users copy the text themselves. This is how Google provides its analytic codes to users for embedding on their sites. I'm sure there was a great way to do this so that Google uses it.

Saving simplicity:

$(function(){ $('.text').click(function(){ $(this).select(); }); }); 

Focus event: http://jsfiddle.net/khXjC/

Click Event: http://jsfiddle.net/qjfgoeLm/

+15
source share

All Articles