验证中...
开源中国 2018 年度最后一场技术盛会邀你来约~错过就要等明年啦!点此立即预约
仿响应式JS来判断页面是在手机端还是在PC端
原始数据 复制代码
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" /> -->
<script type="text/javascript">
function browserRedirect() {
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid = sUserAgent.match(/android/i) == "android";
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
debugger
console.log(sUserAgent);
/* if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) {
// 跳转移动端页面
// window.location.href="http://mobile/index.html";
} else {
// 跳转pc端页面
// window.location.href="http://fanmai/index.html";
} */
}
browserRedirect();
</script>
</head>
<body>
</body>
</html>

评论列表( 0 )

你可以在登录后,发表评论

搜索帮助