1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| function isKeyboardUpFunc () { var u = navigator.userAgent var isAnd = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1 var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) var isSafari = u.indexOf('Safari') > -1 var _that = this if (isAnd) { var oh = document.documentElement.clientHeight || document.body.clientHeight window.addEventListener('resize', function () { var rh = document.documentElement.clientHeight || document.body.clientHeight if (rh !== oh) { _that.isKeyboardUp = true } else { _that.isKeyboardUp = false } }) } if (isIOS && isSafari) { document.body.addEventListener('focusin', function () { _that.isKeyboardUp = true }) document.body.addEventListener('focusout', function () { _that.isKeyboardUp = false }) } }
|