js实现打开网页设备判断

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8" />
<title>js实现打开网页设备判断</title>
<script>
/*判断打开设备*/
var system ={  
	win : false,  
	mac : false,  
	xll : false 
};  
//检测平台   
var p = navigator.platform;  
system.win = p.indexOf("Win") == 0;  
system.mac = p.indexOf("Mac") == 0;  
system.x11 = (p == "X11") || (p.indexOf("Linux") == 0); 
var local= location.href;
//跳转语句   
if(system.win||system.mac||system.xll){
	//此处说明打开该网页设备为pc端
	alert("该设备为PC端");
	//若用移动端网址路径访问则自动跳转到对应pc端路径
	if(local=='http://www.centlight.com/mobile_web.html'){
		window.location.href="http://www.centlight.com/child_web.html";
	}else if(local=='http://www.centlight.com/mobile_ui.html'){
		window.location.href="http://www.centlight.com/child_ui.html";
	}else if(local=='http://www.centlight.com/mobile_php.html'){
		window.location.href="http://www.centlight.com/child_php.html";
	}else{
		window.location.href="http://www.centlight.com/";
	}  
}else{
	//此处说明打开该网页设备为移动端
	alert("该设备为移动端");
	//若用PC端网址路径访问则自动跳转到对应移动端路径
	if(local=='http://www.centlight.com/child_web.html'){
		window.location.href="http://www.centlight.com/mobile_web.html";
	}else if(local=='http://www.centlight.com/child_ui.html'){
		window.location.href="http://www.centlight.com/mobile_ui.html";
	}else if(local=='http://www.centlight.com/child_php.html'){
		window.location.href="http://www.centlight.com/mobile_php.html";
	}else{
		window.location.href="http://www.centlight.com/mobile.html";
	}
}

</script>
</head>
<body>
</body>
</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值