使用javascript检测客户端是否是mobile的类型,如果是就跳转到另外一个页面
<script language="javascript" type="text/javascript">
function Client() { }
Client.prototype.mobileClients = [
"midp",
"240x320",
"blackberry",
"netfront",
"nokia",
"panasonic",
"portalmmm",
"sharp",
"sie-",
"sonyericsson",
"symbian",
"windows ce",
"benq",
"mda",
"mot-",
"opera mini",
"philips",
"pocket pc",
"sagem",
"samsung",
"sda",
"sgh-",
"vodafone",
"xda",
"iphone",
"android",
"ipad"
];
Client.prototype.isMobileClient = function(userAgent) {
userAgent = userAgent.toLowerCase();
for (var i in this.mobileClients) {
if (userAgent.indexOf(this.mobileClients[i]) != -1) {
return true;
}
}
return false;
}
var client = new Client();
if (client.isMobileClient(navigator.userAgent)) {
window.location.href = "http://mobile.html";
}
</script>