庞永胜

Android系统webview调用键盘遮挡输入框问题解决

/*监听input状态,屏幕滚动到input,上下居中
     *在安卓手机上屏幕尺寸变化会产生resize事件。所以监听resize事件。
     *然后定位到input框。
     */
    window.addEventListener('resize', function() {
        if(document.activeElement.tagName === 'INPUT') {
            document.activeElement.scrollIntoView({ behavior: "smooth" });
        }
    })

 

posted @ 2019-01-28 16:39  庞永胜  阅读(413)  评论(0)    收藏  举报