判断客户端是手机访问还是PC访问: var userAgentInfo = navigator.userAgent; var browser1 = userAgentInfo.match("Mobile"); var browser2 = userAgentInfo.match("mobile"); if (browser1 == null && browser2 == null) { //PC访问 }else{ //手机访问 }