移动安卓端,input输入获得焦点被键盘遮住简单解决方案

     (function (window,document) {
          document.querySelector('input[type="text"]').addEventListener('focus',function (e) {
            setTimeout(function () {
              var docHeight = window.innerHeight;
              var bottom = e.target.getBoundingClientRect().bottom;
              var scrollHeight = bottom-docHeight;
              if (scrollHeight > 0) {
                document.body.scrollTop =  scrollHeight+document.body.scrollTop+10
              }
            }, 300)
          }, false)
        })(window,document)
posted @ 2023-03-07 15:40  tianyou_songyk  阅读(47)  评论(0编辑  收藏  举报