页面自动跳转移动端
原理是利用JS判断访问设备的类型,进而跳转,代码如下:
<html>
<head>
</head>
<body >
<script type="text/javascript">
function getCookie(c) {
var b;
return (b = document.cookie.match(RegExp("(^| )" + c + "\x3d([^;]*)(;|$)"))) ? unescape(b[2]) : ""
}
var browse_edition = getCookie("browse_edition");
if ("web" != browse_edition) {
var ua = navigator.userAgent.toLowerCase();
if (/iphone|ipod|android|windows phone|blackberry/.test(ua)) {
this.location = 'http://m.baidu.com';
}
}
</script>
</html>
下一篇
易有太极,始生两仪