gpt4 book ai didi

javascript - 在 ios 中使用 contenteditable ="true"显示 div 的键盘

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:04:31 25 4
gpt4 key购买 nike

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

最佳答案

在 iOS 6 之前这是不可能的,但值得庆幸的是他们已经改变了这一点。一般情况下,您不能为网站执行此操作,但如果您要在应用程序中嵌入 UIWebView,您现在可以执行此操作:

UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
webView.keyboardDisplayRequiresUserAction = NO;

然后您的 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

关于javascript - 在 ios 中使用 contenteditable ="true"显示 div 的键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9766341/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com