How to stop soft keyboard resizing Chrome browser window on Android mobiles?

自古美人都是妖i 提交于 2019-12-11 07:05:09

问题


I see this question asked here, here, here and here, but could not find a clear and/or workable answer. I'm using Android 9 on a Samsung A7 (2018), running Chrome 75.

What happens. I have a html form requiring keyboard input. When opened in Chrome and input is attempted, the keyboard forces the form to resize. The resizing reduces the form to about 50% of the screen height and also resizes the form width and the width/height of input fields. Any text typed is not visible until the keyboard is dismissed and the form returns to normal size. The resizing does not happen in Firefox Focus - the keyboard slides up and over the bottom half of the form, leaving the form at 100% size.

Update 2019 - Solution! I found the answer to my question about Chrome in a question here about the very same problem, but in Firefox (which isn't a problem any more, at least not now with Firefox Focus 9).


回答1:


its an andriod issue where the softkeyboard changes the viewport height...currently working on the same issue...this looks promising, about to implement...it sets the viewport content to explict px values

setTimeout(function () {
    var viewheight = $(window).height();
    var viewwidth = $(window).width();
    var viewport = $("meta[name=viewport]");
    viewport.attr("content", "height=" + viewheight + "px, width=" + 
    viewwidth + "px, initial-scale=1.0");
}, 300);

edit: worked like a charm



来源:https://stackoverflow.com/questions/52384678/how-to-stop-soft-keyboard-resizing-chrome-browser-window-on-android-mobiles

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