微信内置浏览器H5 弹出键盘 遮盖文本框解决办法 Fixed失效

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);
}
})
}


//Fixed失效 监听input框事件
        $("input,textarea").blur(function(){
            setTimeout(function () {
                var scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0;
                window.scrollTo(0, Math.max(scrollHeight - 1, 0));
            },100);
        })

有很多页面是动态画出来的,直接用上面的写法是触发不了的,只能委托给document

 container.on("blur","input,textarea",function(){
     setTimeout(function () {
         var scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0;
         window.scrollTo(0, Math.max(scrollHeight - 1, 0));
     },100);
 })

  

  

借鉴于 http://www.cnblogs.com/Miracle-ZLZ/p/10030608.html

原文地址:https://www.cnblogs.com/tonnytong/p/10049558.html