// 判断ios,iphoneX,androis
function mobileType() {
var u = navigator.userAgent;
var android = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
var ios = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
var iphoneX = false
if (ios) {
// eslint-disable-next-line no-restricted-globals
if (screen.height == 812 ||screen.height === 896) {
//是iphoneX
iphoneX = true
} else {
//不是iphoneX
}
}
return {
android,
ios,
iphoneX
}
}
function IOSInput () {
// 苹果再用
if (mobileType().ios) {
var itimer;
document.body.addEventListener('focusin', function () {
setTimeout(function () {
clearTimeout(itimer);
}, 200);
})
document.body.addEventListener('focusout', function () {
itimer = setTimeout(function () {
window.scroll(0, 0)
}, 300);
})
}
}
// 进来调用一次就可以
IOSInput()
h5中在 iOS 上唤起软键盘,键盘收回后页面不回落
最新推荐文章于 2024-05-09 09:50:03 发布