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.
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?
If not, any advice on how to best implement a user-friendly experience to copy some text to the clipboard on 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)
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.
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?
If not, any advice on how to best implement a user-friendly experience to copy some text to the clipboard on 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)
Share Improve this question edited May 23, 2017 at 12:31 CommunityBot 11 silver badge asked Jul 11, 2012 at 22:48 Ariel VardiAriel Vardi 7971 gold badge7 silver badges18 bronze badges 2- 1 I'm not sure if this applies to iOS, but it's not possible to open context menus using JavaScript. – Alex K Commented Oct 7, 2013 at 20:31
- It wasn't the accepted answer, but this one seems to be the most thorough. Though I'd watch out and test for the strange side effect reported in iOS 7. As @sandstrom suggested, some informative text below/beside the input would probably be the most user friendly approach. – Tom Horwood Commented Oct 8, 2013 at 14:15
2 Answers
Reset to default 3 +50It's not possible unfortunately. I'd include some informative text below the input, hopefully that will work out okay in terms of user-friendliness.
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";
From javascript it is possible with the help of iOS (objective C).
var getVal = $("#textid").val();
localStorage.setItem("getVal",getVal);
and then you can use your native code for getting this value from local storage.
I haven't knowledge of objective C but you can use that's method after js code.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745311334a4622011.html
评论列表(0条)