解决Android 手机下, input 或 textarea 元素聚焦时, 输入法遮盖输入框bug

微信ui解决方案

function androidInputBugFix() {
    if (/Android/gi.test(navigator.userAgent)) {
        window.addEventListener('resize', function () {
            if (document.activeElement.tagName == 'INPUT' || document.activeElement.tagName == 'TEXTAREA') {
                window.setTimeout(function () {
                    document.activeElement.scrollIntoViewIfNeeded();
                }, 0);
            }
        })
    }
};
androidInputBugFix();

 

posted @ 2016-12-15 09:37  李元夕cool  阅读(570)  评论(0编辑  收藏  举报