zoukankan      html  css  js  c++  java
  • 微信内置浏览器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

  • 相关阅读:
    奶酪真香
    规格说明书
    33
    111
    出题
    随笔 01
    我爱奶酪
    用户规格说明书
    第二次结对作业
    结对作业1
  • 原文地址:https://www.cnblogs.com/tonnytong/p/10049558.html
Copyright © 2011-2022 走看看