最近制作了一个二维码,在android平台会进去android下载渠道,如果是ios系统,则进去appStore下载,代码如下
<! DOCTYPE html>
<meta charset= "UTF-8" >
<title>Title</title>
<body style= "font-size:40px;" >
<div id= "Tips" style= "padding:50px 0;width:100%;margin:0 auto;display:none;" >
</div>
</body>
<script type= "Text/javascript" >
Judging the access terminal
var browser={
Versions:function () {
var u = navigator.useragent, app = Navigator.appversion;
return {
Trident:u.indexof (' Trident ') >-1,//ie core
Presto:u.indexof (' presto ') >-1,//opera core
Webkit:u.indexof (' AppleWebKit ') >-1,//Apple, Google kernel
Gecko:u.indexof (' Gecko ') >-1 && u.indexof (' khtml ') = = -1,//Firefox kernel
Mobile:!! U.match (/applewebkit.*mobile.*/),//Whether it is a mobile terminal
Ios:!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/),//ios terminal
Android:u.indexof (' Android ') >-1 | | U.indexof (' Adr ') >-1,//android terminal
Iphone:u.indexof (' iphone ') >-1,//whether for iphone or Qqhd browser
Ipad:u.indexof (' ipad ') >-1,//whether ipad
Webapp:u.indexof (' Safari ') = =-1,//whether the Web should be program, no head with bottom
Weixin:u.indexof (' Micromessenger ') >-1,//whether (added 2015-01-22)
Qq:u.match (/\sqq/i) = = "QQ"//whether QQ
};
}(),
Language: (Navigator.browserlanguage | | navigator.language). toLowerCase ()
};
if (!browser.versions.mobile) {
If not mobile scan QR code
Alert ("Please scan the QR code with your phone");
}else if (browser.versions.android) {
If Android, go directly to the download link
location.href= ' http://url.cn/42G7PNz ';
}
else if (browser.versions.weixin && (Browser.versions.ios | | browser.versions.iPad)) {
If it is an iOS system and is turned on, a reminder is displayed (direct jump AppStore not supported)
document.getElementById ("Tips"). Style.display = "block";
}else if (Browser.versions.ios | | browser.versions.iPad) {
If it is an iOS system and is not open in, jump directly to AppStore
location.href= ' https://itunes.apple.com/cn/app/sui-shi-bao/id1097442883?mt=8 ';
}
</script>
最后用二维码生成器,把此页面生成二维码即可
JavaScript to judge the access terminal