~~~
<script>
var user=ispc()?"电脑":"手机";
document.write(user);
if (ispc()) {
document.write('<script src="\/javascripts\/application.js" type="text\/javascript" charset="utf-8"><\/script>');
};
function ispc() {
var userAgentInfo = navigator.userAgent;
var Agents = ["Android", "iPhone",
"SymbianOS", "Windows Phone",
"iPad", "iPod"];
var flag = true;
for (var v = 0; v < Agents.length; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false;
break;
}
}
return flag;
}
</script>
~~~
##一段不错的判断手机站并跳转的js代码
~~~
var mobile=1;
if(mobile==1){
var is_mobi = navigator.userAgent.toLowerCase().match(/(xiaomi|mobile|iphone|android|wap|netfront|java|operasmini|ucweb|windowssce|symbian|series|webos|sonyericsson|sony|blackberry|cellphone|dopod|nokia|samsung|palmsource|xphone|xda|smartphone|pieplus|meizu|midp|cldc)/i) != null;
if(is_mobi){
window.location.href=site_url+'/Wap/index';
}
}
~~~