解决ios微信下软键盘收起后,页面留白
作者:互联网
//解决底部空白 (function () { let myFunction let isWXAndIos = isWeiXinAndIos() if (isWXAndIos) { document.body.addEventListener('focusin', () => { clearTimeout(myFunction) }) document.body.addEventListener('focusout', () => { clearTimeout(myFunction) myFunction = setTimeout(function() { window.scrollTo({top: 0, left: 0, behavior: 'smooth'}) }, 200) }) } })(); function isWeiXinAndIos () { let ua = '' + window.navigator.userAgent.toLowerCase() let isWeixin = /MicroMessenger/i.test(ua) let isIos = /\(i[^;]+;( U;)? CPU.+Mac OS X/i.test(ua) return isWeixin && isIos } //解决底部空白 end
标签:myFunction,function,微信,ios,let,clearTimeout,留白,ua,isWeiXinAndIos 来源: https://www.cnblogs.com/sdsd123/p/11161926.html