webpage skip between PC to moblie ;(function () { var isMobile = false // 默认PC端 function mobile() { try { document.createEvent("TouchEvent") return true } catch (e) { return false } } isMobile = mobile() var str = window.location.href
;(function () {
var isMobile = false // 默认PC端
function mobile() {
try {
document.createEvent("TouchEvent")
return true
}
catch (e) {
return false
}
}
isMobile = mobile()
var str = window.location.href
if (isMobile && str.indexOf('https://m.') === -1) {
//移动端的处理逻辑
str = str.replace('https://', 'https://m.')
window.location.href = str
}
if (!isMobile && str.indexOf('https://m.') !== -1) {
//PC端的处理逻辑
str = str.replace('https://m.', 'https://')
window.location.href = str
}
})()
