微信H5页面中软键盘收回时页面不回弹

问题:在微信H5中 ios12 软键盘收回时页面不回弹,导致光标位置错乱,再次点击输入框区域时无法focus
解决思路:失去焦点时滚动下页面
    let ua = window.navigator.userAgent;
    if (!!ua.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)) {
        //$alert('ios端');
        oInput.onblur = function () {
            var currentPosition, timer;
            var speed = 1;
            timer = setInterval(function () {
                currentPosition = document.documentElement.scrollTop || document.body.scrollTop;
                currentPosition -= speed;
                window.scrollTo(0, currentPosition); //页面向上滚动
                currentPosition += speed;
                window.scrollTo(0, currentPosition); //页面向下滚动
                clearInterval(timer);
            }, 100);
        }
    } else if (ua.indexOf('Android') > -1 || ua.indexOf('Adr') > -1) {
        // console.log('安卓正常')
    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。