js判断是PC端还是手机端

if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|Windows Phone/i.test(navigator.userAgent)) {

    window.location.href = "https://www.baidu.com/";   //pc链接调转

} else {

    window.location.href = "http://news.baidu.com/";   //手机链接跳转

}

你可能感兴趣的:(js判断是PC端还是手机端)