<script>
// 检测 userAgent(浏览器信息)
!(function () {
const userAgent = navigator.userAgent
// 验证是否为Android或iPhone
const android = userAgent.match(/(Android);?[\s\/]+([\d.]+)?/)
const iphone = userAgent.match(/(iPhone\sOS)\s([\d_]+)/)
// 如果是Android或iPhone,则跳转至移动端站点
if (android || iphone) {
location.href = 'http://m.itcast.cn'
}
})()
</script>
BOM:navigator对象中的userAgent(验证是否为移动端,如果是则跳转至移动端站点)
最新推荐文章于 2022-06-30 00:02:16 发布