天天看点

移动端,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
         }
     },400)
    },false)
})(window,document)      
//可以解决部分代码的      

  

http://www.cnblogs.com/jiebba/p/8405772.html

    更好的解决方案在这里

上一篇: js-柯里化
下一篇: js的jsonp