###苹果iphone ios系统 键盘弹起导致页面高度发生变化,无法回弹的解决方案
~code~
document.body.addEventListener('focusin', () => {
// 软键盘弹起事件
var scrollTop = 0
if (document.documentElement && document.documentElement.scrollTop) {
scrollTop = document.documentElement.scrollTop
} else if (document.body) {
scrollTop = document.body.scrollTop
}
window.workrelateScrollTop = scrollTop
})
document.body.addEventListener('focusout', () => {
// 软键盘关闭事件
var ua = window.navigator.userAgent
if (ua.indexOf('iPhone') > 0 || ua.indexOf('iPad') > 0) {
// 键盘收起页面空白问题
document.body.scrollTop = window.workrelateScrollTop
document.documentElement.scrollTop = window.workrelateScrollTop
}
})