显示div的键盘,其中contenteditable =" true"在ios [英] Show keyboard for div with contenteditable="true" in ios
问题描述
我有一个contenteditable =true的div。如何通过javascript设置对此div的关注(如果可以在纯js上,没有jquery)?
I have a div with contenteditable="true". How can I set focus on this div via javascript(if it possible on pure js, without jquery)?
推荐答案
在iOS 6之前,这是不可能的,但幸好他们已经改变了。一般情况下,您无法为网站执行此操作,但如果您在应用程序中嵌入 UIWebView
,则可以立即执行此操作:
Prior to iOS 6 this wasn't possible, but thankfully they've changed that. You can't do it in general for a website, but if you are embedding a UIWebView
in your application you can do it now:
UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
webView.keyboardDisplayRequiresUserAction = NO;
然后你的 element.focus()
将根据需要工作并调出键盘。
Then your element.focus()
will work and bring up the keyboard as desired.
有关iOS 6& A更改内容的更多信息WebKit:
More info on what changed with iOS 6 & WebKit:
这篇关于显示div的键盘,其中contenteditable =" true"在ios的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!