显示div的键盘,其中contenteditable =" true"在ios [英] Show keyboard for div with contenteditable="true" in ios

查看:298
本文介绍了显示div的键盘,其中contenteditable =" true"在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.

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

有关iOS 6& A更改内容的更多信息WebKit:

More info on what changed with iOS 6 & WebKit:

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

这篇关于显示div的键盘,其中contenteditable =" true"在ios的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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