显示Android的软键盘,当一个字段是.focus()倒是使用JavaScript [英] Showing Android's soft keyboard when a field is .focus()'d using javascript

查看:156
本文介绍了显示Android的软键盘,当一个字段是.focus()倒是使用JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个网页我有一个搜索栏。我添加了一个清除按钮,以便用户可以清除搜索字段并重新开始。为方便起见,我专注搜索领域的文本框,光标会出现在框中。然而,软键盘似乎并没有显示在使用默认浏览器的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

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

这篇关于显示Android的软键盘,当一个字段是.focus()倒是使用JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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