admin管理员组文章数量:1530051
在很多时候,下载app需要将android和ios的下载链接集成到同一个二维码上自动识别设备。这时就需要用一个网页进行中转来识别设备进而返回相应的url,具体的代码如下:
<!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 = '您的默认url';
if(Terminal.platform.android){ //安卓
theUrl = '您的android下载地址';
}else if(Terminal.platform.iPhone){ //ios
theUrl = '您的ios下载地址';
// }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>
<!--
-->
</body>
</html>
html下载地址:http://download.csdn/detail/qq952290156/9847087
版权声明:本文标题:二维码跳转android或ios下载app中转处理 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1726630624a1079148.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论