h5 解決ios和 Android 輸入框無法擡起和ios留白處理:
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android終端
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios終端
if (isiOS) {
document.body.addEventListener('focusin', () => {
setTimeout(()=>{
document.body.scrollTop=document.body.scrollHeight;
},100)
})
document.body.addEventListener('focusout', () => {
window.scrollTo({ top: 0, left: 0, behavior: 'smooth' })
})
}
if (/Android/gi.test(navigator.userAgent)) {
window.addEventListener('resize', function () {
if (document.activeElement.tagName == 'INPUT' || document.activeElement.tagName == 'TEXTAREA') {
window.setTimeout(function () {
document.activeElement.scrollIntoView();
}, 100);
}
}.bind(this))
}