Html input loses focus on Samsung Android when virtual keyboard appears

隐身守侯 提交于 2019-12-24 09:28:08

问题


I have the problem of losing focus on an input element on a Samsung Galaxy Tab A (Android 7.0) with a html5 web application. It seems to be a problem in android, as on windows 10 or iOS (although the resize event is also triggered when the virtual keyboard pops up) the element does not lose focus. Windows 10 and iOS apparently suppress this when the virtual keyboard is called (but not when manually resizing the browser window). Anybody any help on this?


回答1:


It's an Android issue losing focus due to the resize() event.

Have you tried something like this for your resize functionality if something is not in focus:

$(window).bind('resize', function() {

    if ($("input").is(":focus")) {
        // Nothing will happen
    } else {
        // Other resize functions
    }
});


来源:https://stackoverflow.com/questions/44433969/html-input-loses-focus-on-samsung-android-when-virtual-keyboard-appears

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!