您的位置:首页 > 移动开发

web app ,输入框被Android 键盘遮挡

2018-04-03 16:45 274 查看
if (/Android/gi.test(navigator.userAgent)) {
window.addEventListener(
4000
'resize', function () {  
if (document.activeElement.tagName == 'INPUT' || document.activeElement.tagName == 'TEXTAREA') {  
window.setTimeout(function () {         
document.activeElement.scrollIntoViewIfNeeded();
}, 0);
}
})
}


说明:

Element.scrollIntoViewIfNeeded()方法用来将不在浏览器窗口的可见区域内的元素滚动到浏览器窗口的可见区域
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: