判断是否是手机访问,安卓或IOS
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
</head>
<body>
<script>
var browser = {
versions: function() {
var u = navigator.userAgent,app = navigator.appVersion;
return { //移动终端浏览器版本信息
ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或uc浏览器
iPhone: u.indexOf('iPhone') > -1,//是否为iPhone或者QQHD浏览器
iPad: u.indexOf('iPad') > -1,//是否iPad
};
}(),
} // JavaScript Document
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); //跳转语句
if(system.win || system.mac || system.xll) {
alert("电脑 写电脑地址window.location.href='123.com'");
} else {
if(browser.versions.iPhone || browser.versions.iPad || browser.versions.ios) {
alert("手机 写IOS地址window.location.href='123.com'");
}
if(browser.versions.android) {
alert("手机android 写android地址window.location.href='123.com'");
}
}
</script> </body>
</html>