Copy to Clipboard that also works on Mobile?

后端 未结 2 1645
盖世英雄少女心
盖世英雄少女心 2020-12-16 02:07

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 mean

2条回答
  •  伪装坚强ぢ
    2020-12-16 02:38

    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+.

提交回复
热议问题