判断页面是在移动端还是PC端打开的

window.location.href = /Android|webOS|iPhone|iPad|BlackBerry/i.test(navigator.userAgent) ? "https://www.baidu.com/" :  "http://news.baidu.com/";
if(/Android|webOS|iPhone|iPad|BlackBerry/i.test(navigator.userAgent)) {
    window.location.href = "https://www.baidu.com/";
} else {
    window.location.href = "http://news.baidu.com/";
}

转载于:https://www.cnblogs.com/jassy/p/8342358.html

你可能感兴趣的:(判断页面是在移动端还是PC端打开的)