显示Android的软键盘,当一个字段是.focus()倒是使用JavaScript字段、键盘、Android、focus

由网友(嘲笑我懦弱)分享简介:在一个网页我有一个搜索栏。我添加了一个清除按钮,以便用户可以清除搜索字段并重新开始。为方便起见,我专注搜索领域的文本框,光标会出现在框中。然而,软键盘似乎并没有显示在使用默认浏览器的Andr​​oid设备。在iOS和Opera移动它的工作原理是,我期望。有一个额外的方法我可以调用,这将导致键盘的Andr​​oid的浏览...

在一个网页我有一个搜索栏。我添加了一个清除按钮,以便用户可以清除搜索字段并重新开始。为方便起见,我专注搜索领域的文本框,光标会出现在框中。然而,软键盘似乎并没有显示在使用默认浏览器的Andr​​oid设备。在iOS和Opera移动它的工作原理是,我期望。

有一个额外的方法我可以调用,这将导致键盘的Andr​​oid的浏览器中显示,这样用户就可以开始打字的时候了?

 函数clear_search(){
    如果($('#searchinput')。VAL()){
        $('#searchinput)VAL('')。
    }
    $('#searchinput)专注()。
}
 

解决方案

我不是100%肯定,但我认为它不能老是做(至少要等到Android 2.2的)从JavaScript。如果你正在使用PhoneGap的,你可以使用这个位置:的https://github.com/phonegap/phonegap/wiki/How-to-show-and-hide-soft-keyboard-in-Android

android软键盘的显示后隐藏

In a web-page I've got a search field. I've added a "clear" button so that users can clear the search field and start again. As a convenience, I focus the search field's text box and the cursor does appear in the box. However the soft keyboard does not seem to show up on android devices that use the default browser. In iOS and Opera Mobile it works as I'd expect.

Is there an additional method I can call that will cause the keyboard to show on Android's browser so the user can start typing right away?

function clear_search() {
    if($('#searchinput').val()) {
        $('#searchinput').val('');
    }
    $('#searchinput').focus();
}

解决方案

I am not 100% sure but I think it can`t be done (at least until android 2.2) from javascript. If you are using phonegap you can use this here: https://github.com/phonegap/phonegap/wiki/How-to-show-and-hide-soft-keyboard-in-Android

阅读全文

相关推荐

最新文章