在ios中显示div的键盘与contenteditable ="true"

Sia*_*sou 2 javascript contenteditable ios

我有一个contenteditable ="true"的div.如何通过javascript设置焦点(如果可以在纯js,没有jquery)?

Ada*_*dam 7

在iOS 6之前,这是不可能的,但幸运的是他们改变了这一点.您不能一般地为网站执行此操作,但如果您UIWebView在应用程序中嵌入了一个,则可以立即执行:

UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
webView.keyboardDisplayRequiresUserAction = NO;
Run Code Online (Sandbox Code Playgroud)

然后你的element.focus()工作将根据需要调出键盘.

http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIWebView_Class/Reference/Reference.html#//apple_ref/occ/instp/UIWebView/keyboardDisplayRequiresUserAction

有关iOS 6和WebKit发生了哪些变化的更多信息:

http://developer.apple.com/library/ios/#releasenotes/General/RN-iOSSDK-6_0/_index.html#//apple_ref/doc/uid/TP40012166-CH1-SW19