首页 > 代码库 > 做网站首页制作手机端浏览的跳转

做网站首页制作手机端浏览的跳转

<script language="javascript"> 

if(!IsPC()){

window.location.href=http://www.mamicode.com/"/m/"; //要跳转的地址,也可以跳转到 window.location.href="http://m.xxx.com/";
}
function IsPC()
{
var userAgentInfo = navigator.userAgent;  
var Agents = new Array("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>