我可以触发Android的软键盘打开通过javascript(不PhoneGap的)?键盘、Android、PhoneGap、javascript

2023-09-04 23:28:31 作者:淮北辰

我有一些自定义的Web组件在我的移动Web应用程序,而我需要手动开火场焦点事件,以模拟在Android软键盘功能下一步的功能。 (使用银河S3原生浏览器)。

然而,当我手动触发一个'选择'领域的焦点事件,本机软键盘没有显示。我随后单击该字段来得到它显示。 (在IOS,当然,它工作得很好)。

所以,我想知道,如果一个焦点事件不会触发软键盘打开,有什么JS事件将???

我不使用PhoneGap的,所以我希望有没有它的方式。

感谢您的帮助!

解决方案

下面是从StackOverflow的一个链接:

  

Showing Android的软键盘,当一个字段是.focus()处理使用JavaScript

     

只是侧重不似乎没有工作的事件。 - 你需要一个   单击事件触发这一点。

  $(文件)。就绪(函数(){
    $('#场)。点击(函数(五){
        $(本).focus();
    });
    $('#键)。点击(函数(五){
        $('#场)的触发器(点击)。
    });
});
 

android软键盘的显示后隐藏

I have some custom web components in my mobile web app, whereas I need to manually fire 'focus' events on a field, to simulate the 'NEXT' functionality in the Android soft keyboard feature. ( using Galaxy S3 native browser ).

However, when I manually fire a focus event on a 'select' field, the native soft keyboard does not show. I have to subsequently click on the field to get it to show. (In IOS, of course, it works just fine).

So I'm wondering, if a 'focus' event doesn't trigger the soft keyboard to open, what JS event will ???

I am not using phonegap so I'm hoping there's a way without it.

Thanks for any help!!!

解决方案

Here's a link from StackOverflow:

Showing Android's soft keyboard when a field is .focus()'d using javascript

Just focussing without an event doesnt seem to work. - you DO need a click event triggering this.

$(document).ready(function() {
    $('#field').click(function(e){
        $(this).focus();
    });
    $('#button').click(function(e) {
        $('#field').trigger('click');
    });
});