[英]jQuery .focus() not working in Android webview
I am trying to focus the input field on page loaded, so I used $(selector).focus()
after the content loaded.我试图将输入字段集中在加载的页面上,所以我在加载内容后使用
$(selector).focus()
。 It working on desktop and chrome browser in Android, but when I load the same page in a webview in Android, it's not working.它在 Android 中的桌面和 chrome 浏览器上工作,但是当我在 Android 的 webview 中加载同一页面时,它不起作用。
I googled about this focus issue, I found couple attributes for webview so I added them, but still it's not working我用谷歌搜索了这个焦点问题,我发现了 webview 的几个属性,所以我添加了它们,但它仍然不起作用
<WebView
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_weight="1"
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="0dp" />
Note : The webview is inside a bottom sheet fragment.注意:webview 位于底部薄片片段内。
try this尝试这个
webview.getsettings().setjavascriptenabled(true);
update更新
//add this before you webview load url
webview.requestFocus();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.