H5在微信ios端input框键盘弹起导致页面变形

var u = navigator.userAgent, app = navigator.appVersion;

var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端

//此方法写在input框内

function getPan(){

if(isIOS){

temporaryRepair();

}

}

function temporaryRepair(){

    var currentPosition,timer;

    var speed=1;//页面滚动距离

    timer=setInterval(function(){

        currentPosition=document.documentElement.scrollTop || document.body.scrollTop;

        currentPosition-=speed;

        window.scrollTo(0,currentPosition);//页面向上滚动

        currentPosition+=speed; //speed变量

        window.scrollTo(0,currentPosition);//页面向下滚动

        clearInterval(timer);

    },1);

}

html代码

<input type="text"  placeholder="姓名" id="name" onblur="getPan()"/>

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。