JS判断浏览器是否为移动端
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>手机首页</title>
</head>
<body>
<h1>手机首页</h1><hr>
<script>
if(navigator.platform.indexOf('Win32')!=-1){
//pc
document.write("PC");
}else{
//shouji
//window.location.href="手机网址";
document.write("Phone");
}
</script>
<!-- 判断移动终端 -->
<script type="text/javascript">
var mobileAgent = new Array("iphone", "ipod", "ipad", "android", "mobile", "blackberry", "webos", "incognito", "webmate", "bada", "nokia", "lg", "ucweb", "skyfire");
var browser = navigator.userAgent.toLowerCase();
var isMobile = false;
for (var i=0; i<mobileAgent.length; i++){
if (browser.indexOf(mobileAgent)!=-1){
isMobile = true;
alert(mobileAgent);
//location.href = '手机网址';
break;
}
}
</script>
</body>
</html>
页:
[1]