1判断浏览器函数
// 判断浏览器函数
function isMobile() {
if (
window.navigator.userAgent.match(
/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
)
) {
return true // 移动端
} else {
return false // PC端
}
}
2 手机端判断苹果还是安卓
function isIos() {
if (window.navigator.userAgent.match(/(iPhone|iPod|ios|iPad)/i)) {
return true // ios
} else {
return false // 其他
}
}
3.
function getBoxHeightToFullScreen(node) {
function getOffsetTop(el) {
return el.offsetParent
? el.offsetTop + getOffsetTop(el.offsetParent)
: el.offsetTop
}
const screenHeight = document.documentElement.clientHeight
console.log('screenHeight', screenHeight)
return screenHeight - getOffsetTop(node)
}
|