我试图让 iphone 用户可以轻松地将一些文本复制到移动 safari 中的剪贴板.就像通常的触摸保持复制"一样.我希望用户复制一段特定的文本.我可以完全选择用于包装文本的 html 标记.我怎样才能让它变得容易,而不是随意?例如:
I'm trying to make it easy for an iphone user to copy some text to the clipboard in mobile safari. As in the usual "touch-hold-copy". There is a specific bit of text I want to a user to copy. I have full choice of the html markup in which to wrap the text. How can I make it easy, rather than abitrary? For instance:
有没有办法在使用 javascript 触地时全选"文本?那么用户可以继续长按然后选择复制吗?
Is there a way to "select all" the text upon touch-down using javascript? Then a user could just continue to touch-hold and then choose copy?
有没有办法调出全选"选项?就像在文本框中输入时一样?之后他们可以选择复制?
Is there a way to bring up the "select all" option? Like you can when typing in a text box? After which they can choose copy?
如果没有 javascript 解决方案,我该如何安排 html 以帮助 Safari 轻松选择正确的文本位?而不是一个词,或者一个包装的 div?
If there's no javascript solution, how can I arrange the html to help Safari select the right bit of text easily? As opposed to just a word, or a wrapping div?
我已经为各种元素尝试过 onFocus="this.select()" ,但似乎都不起作用.也试过onClick.
I've tried onFocus="this.select()" for various elements, none seem to work. Also tried onClick.
那些尝试将使用 ZeroClipboard 的网站移植到 iPhone 上的人可能会有一些想法.
Those who have tried to port a site that uses ZeroClipboard to the iPhone might have some ideas.
干杯
而不是 this.select();
我使用了以下,它成功了!
instead of this.select();
I used the following and it worked!
this.selectionStart=0;
this.selectionEnd=this.value.length;
这篇关于在 iPhone 上的移动 Safari 中选择文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!