复制到也适用于移动设备的剪贴板? [英] Copy to Clipboard that also works on Mobile?

查看:20
本文介绍了复制到也适用于移动设备的剪贴板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我熟悉 ZeroClipboard 和 jquery.copy,它们都使用 Flash.好的,所以我明白了,出于浏览器安全原因,不允许复制,我们需要 Flash.但这意味着复制功能在手机(iPhone、Android)或 iPad 中不起作用.

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.

是否有任何资源或插件可以在现代浏览器(包括 IE7+)和移动浏览器上实现简单的复制到剪贴板功能?

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

谢谢!

推荐答案

我只是想提供一个更新,因为最近在这方面有了一些进展.现代浏览器,除了 Safari 支持通过 JS 复制,使用 execCommand() api.

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.

假设您构建的 UI 可以优雅地降级为 Safari 的手动复制,您可以在其余的 UI 上实现复制到剪贴板.据推测,Safari 最终会包含对此的支持.

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.

查看 https://clipboardjs.com/http://www.sitepoint.com/javascript-copy-to-clipboard/ 选项.

在撰写本文时支持的浏览器:Chrome 42+、Firefox 41+、IE 9+、Opera 29+.

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

这篇关于复制到也适用于移动设备的剪贴板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆