通过浏览器,javascript判断 ios 系统版本
2014-05-06 12:02
453 查看
1.因为根据7.1 系统用的安装地址是 itms-services://?action=download-manifest&url=https://example.com/manifest.plist
而<7.1 的版本为itms-services://?action=download-manifest&url=http://example.com/manifest.plist
所以需要在浏览器中进行判断
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Setup Intall App By xxxxx</title>
<style type="text/css">
body{ background:#EFEFEF; font-family:Arial; font-size:40px;}
</style>
<script type="text/javascript">
window.addEventListener('load', function() {
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid = sUserAgent.match(/android/i) == "android";
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
var b = document.getElementById('downloadHref');
var plistPath = b.href;
if(bIsIphoneOs){
var ios7 = Boolean(navigator.userAgent.match(/OS [7-9]_\d[_\d]* like Mac OS X/i));
if(ios7){
var ios71 = Boolean(navigator.userAgent.match(/OS [7-9]_1[_\d]* like Mac OS X/i));
if(ios71){
//default is https
}else{
var finlaPath = plistPath.replace("https","http");
b.href=finlaPath;
}
}else{
var finlaPath = plistPath.replace("https","http");
b.href=finlaPath;
}
}
}, false);
</script>
</head>
<body>
<div>
<table width="100%" height="100%">
<tr >
<td align="center">
<a id="downloadHref" href="itms-services:///?action=download-manifest&url=https://XXX.XXXX/test/manifest.plist">
<font color="#369999">*Please Tap to Install.Thanks</font>
</a>
</td>
</tr>
</table>
</div>
</body>
</html>
而<7.1 的版本为itms-services://?action=download-manifest&url=http://example.com/manifest.plist
所以需要在浏览器中进行判断
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Setup Intall App By xxxxx</title>
<style type="text/css">
body{ background:#EFEFEF; font-family:Arial; font-size:40px;}
</style>
<script type="text/javascript">
window.addEventListener('load', function() {
var sUserAgent = navigator.userAgent.toLowerCase();
var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
var bIsMidp = sUserAgent.match(/midp/i) == "midp";
var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4";
var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb";
var bIsAndroid = sUserAgent.match(/android/i) == "android";
var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce";
var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile";
var b = document.getElementById('downloadHref');
var plistPath = b.href;
if(bIsIphoneOs){
var ios7 = Boolean(navigator.userAgent.match(/OS [7-9]_\d[_\d]* like Mac OS X/i));
if(ios7){
var ios71 = Boolean(navigator.userAgent.match(/OS [7-9]_1[_\d]* like Mac OS X/i));
if(ios71){
//default is https
}else{
var finlaPath = plistPath.replace("https","http");
b.href=finlaPath;
}
}else{
var finlaPath = plistPath.replace("https","http");
b.href=finlaPath;
}
}
}, false);
</script>
</head>
<body>
<div>
<table width="100%" height="100%">
<tr >
<td align="center">
<a id="downloadHref" href="itms-services:///?action=download-manifest&url=https://XXX.XXXX/test/manifest.plist">
<font color="#369999">*Please Tap to Install.Thanks</font>
</a>
</td>
</tr>
</table>
</div>
</body>
</html>
相关文章推荐
- 通过JavaScript判断当前浏览器版本
- 通过javascript判断浏览器类型以及版本
- JavaScript判断浏览器的类型和版本
- javascript判断浏览器类型与版本
- JavaScript判断浏览器类型及版本
- 通过关键系统文件判断正确的操作系统版本
- JavaScript 判断浏览器及版本
- JavaScript 判断浏览器类型及版本
- JavaScript判断浏览器类型及版本
- jQuery javaScript js 判断浏览器的类型、版本的方法
- JS通过分析userAgent属性来判断浏览器的类型及版本
- 通过判断浏览器的userAgent,用正则来判断手机是否是ios(苹果)和Android(安卓)客户端
- JavaScript判断浏览器版本
- 如何用JavaScript判断客户端浏览器是否安装了Flash插件,及其版本
- JavaScript判断浏览器类型及版本
- javascript判断浏览器类型与版本
- 通过JS判断浏览器类型,详细区分IE各版本浏览器
- javascript 判断浏览器版本
- 如何用JavaScript判断客户端浏览器是否安装了Flash插件,及其版本?【转】