Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I see this question asked 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).

like image 242
plugincontainer Avatar asked Sep 18 '18 10:09

plugincontainer


1 Answers

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

like image 86
sallycakes Avatar answered Sep 18 '22 01:09

sallycakes