jQuery .focus() 在 Android webview 中不工作
jQuery .focus() not working in Android webview
我试图将输入字段集中在加载的页面上,所以我在内容加载后使用了 $(selector).focus()
。它在 Android 中的桌面和 chrome 浏览器上工作,但是当我在 Android 中的网络视图中加载同一页面时,它不起作用。
我用谷歌搜索了这个焦点问题,我发现了 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" />
注意:网络视图位于底部 sheet 片段内。
试试这个
webview.getsettings().setjavascriptenabled(true);
更新
//add this before you webview load url
webview.requestFocus();
我试图将输入字段集中在加载的页面上,所以我在内容加载后使用了 $(selector).focus()
。它在 Android 中的桌面和 chrome 浏览器上工作,但是当我在 Android 中的网络视图中加载同一页面时,它不起作用。
我用谷歌搜索了这个焦点问题,我发现了 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" />
注意:网络视图位于底部 sheet 片段内。
试试这个
webview.getsettings().setjavascriptenabled(true);
更新
//add this before you webview load url
webview.requestFocus();