教你制作自动识别手机系统并进入相应地址
把以下代码保存为一个html文件,放入站点,设置好识别设备后进入的下载地址(如同本站的二维码客户端一样可以识别iphone和Android并进入不同下载页面)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | <!DOCTYPE HTML>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>手机APP下载页面:根据终端辨别下载地址</title>
<script type="text/javascript">
// 获取终端的相关信息
var Terminal = {
// 辨别移动终端类型
platform : function(){
var u = navigator.userAgent, app = navigator.appVersion;
return {
// android终端或者uc浏览器
android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
// 是否为iPhone或者QQHD浏览器
iPhone: u.indexOf('iPhone') > -1 ,
// 是否iPad
iPad: u.indexOf('iPad') > -1
};
}(),
// 辨别移动终端的语言:zh-cn、en-us、ko-kr、ja-jp...
language : (navigator.browserLanguage || navigator.language).toLowerCase()
}
// 根据不同的终端,跳转到不同的地址
var theUrl = 'http://www.linlik.com';
if(Terminal.platform.android){
theUrl = 'http://bbs.linlik.com/app/zidingyi/LinLi_Android.apk';
}else if(Terminal.platform.iPhone){
theUrl = 'http://bbs.linlik.com/app/zidingyi/LinLi_iPhone.ipa';
}else if(Terminal.platform.iPad){
// 还可以通过language,区分开多国语言版
switch(Terminal.language){
case 'en-us':
theUrl = '你的iPad APP(英文版)对应下载地址:APP Store地址';
break;
case 'ko-kr':
theUrl = '你的iPad APP(韩语版)对应下载地址:APP Store地址';
break;
case 'ja-jp':
theUrl = '你的iPad APP(日文版)对应下载地址:APP Store地址';
break;
default:
theUrl = '你的iPad APP(中文版-默认)对应下载地址:APP Store地址';
}
}
location.href = theUrl;
</script>
</head>
<body>
<!--
有啥问题,请直接到这里来反馈:http://linlik.com
-->
</body>
</html> |

😛 这个不错,可以尝试下,博主还有其他的吗?多分享分享哦
2015-11-24 下午 3:50