使用javascript在iOS safari中以编程方式触发复制菜单? [英] Programmatically trigger copy menu in iOS safari using javascript?

查看:129
本文介绍了使用javascript在iOS safari中以编程方式触发复制菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图实现一种用户友好的方式将一些文本从文本输入字段复制到iOS / Safari上的剪贴板。我知道有没有办法在这个平台上以编程方式做,但我希望我可以尽可能指导用户体验。

I'm trying to implement a user-friendly way to copy some text from a text input field to the clipboard on iOS/Safari. I understand there is no way to programmatically do it on this platform, but I was hoping I could guide the user experience as much as possible.

在iOS / Safari上,当用户手动突出显示某些文本时,会弹出一个上下文复制菜单。我希望同样的菜单会弹出,当文本以编程方式选择,但它不会。

On iOS/Safari, when a user manually highlights some text, a contextual Copy menu pops up. I was hoping the same menu would pop up when the text is selected programmatically, but it doesn't. Is it even possible to do that?

如果没有,任何建议如何最好地实现用户友好的体验,以复制一些文本到iOS / Safari上的剪贴板?

If not, any advice on how to best implement a user-friendly experience to copy some text to the clipboard on iOS/Safari?

作为参考,我使用此问题中描述的方法选择文本:
以编程方式在iOS设备(移动Safari)上的输入字段中选择文本

For reference, I'm selecting the text using the method described in this question: Programmatically selecting text in an input field on iOS devices (mobile Safari)

推荐答案

这是不可能的。我将在输入下面包括一些信息性文本,希望在用户友好性方面做得很好。

It's not possible unfortunately. I'd include some informative text below the input, hopefully that will work out okay in terms of user-friendliness.

另一种选择是去原生,通过使用PhoneGap包装,但我想你已经知道这个选项。如果是这样,这样的东西将工作在本机代码:

Another option would be to go native, e.g. by wrapping using PhoneGap, but I guess you are already well aware of that option. If so, something like this would work in native code:

[UIPasteboard generalPasteboard].string = @"your string";

这篇关于使用javascript在iOS safari中以编程方式触发复制菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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