您的位置:首页 > Web前端 > JavaScript

通过浏览器,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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: