HTML5 虚拟键盘出现挡住输入框的解决办法

话不多说,请看代码:

//防止键盘把当前输入框给挡住$$(input[type="text"],textarea).on(click, function () {  var target = this;  setTimeout(function(){        target.scrollIntoViewIfNeeded();   },100);});

部分安卓机型适用。

if(/Android [4-6]/.test(navigator.appVersion)) {    window.addEventListener("resize", function() {        if(document.activeElement.tagName=="INPUT" || document.activeElement.tagName=="TEXTAREA") {            window.setTimeout(function() {document.activeElement.scrollIntoViewIfNeeded();            },0);        }    })}

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持脚本之家!

HTML5 虚拟键盘出现挡住输入框的解决办法