你的位置:首页 > Java教程

[Java教程]js判断浏览器信息(移动端PC端)


var userAgent = navigator.userAgent;userAgent = userAgent.toLowerCase();var isMobile = "false";if (userAgent.indexOf("android") >= 0 || userAgent.indexOf("mini 9.5") >= 0 || userAgent.indexOf("vx1000") >= 0 || userAgent.indexOf("lge") >= 0 || userAgent.indexOf("m800") >= 0 || userAgent.indexOf("3g_t") >= 0 || userAgent.indexOf("windows ce") >= 0 || userAgent.indexOf("opera mobi") >= 0 || userAgent.indexOf("windows ce; smartphone;") >= 0 || userAgent.indexOf("windows ce; iemobile") >= 0 || userAgent.indexOf("ipod") >= 0 || userAgent.indexOf("ipad") >= 0 || userAgent.indexOf("iphone") >= 0 || userAgent.indexOf("opera mini") >= 0 || userAgent.indexOf("blackberry") >= 0 || userAgent.indexOf("palm os") >= 0 || userAgent.indexOf("palm") >= 0 || userAgent.indexOf("mobile") >= 0 || userAgent.indexOf("hiptop") >= 0 || userAgent.indexOf("avantgo") >= 0 || userAgent.indexOf("fennec") >= 0 || userAgent.indexOf("plucker") >= 0 || userAgent.indexOf("xiino") >= 0 || userAgent.indexOf("blazer") >= 0) {  isMobile = "true";}if (isMobile == "true") {  window.location.href = "http://www.mobilePage.com";}else{  window.location.href = "http://www.PCWebPage.com";}