用一个二维码做下载地址,自动区分是 ios 还是 android, 甚至区分 iphone 和 ipad。
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
| <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>二维码下载</title> <script type="text/javascript"> /* * 智能机浏览器版本信息: * */ var browser = { versions: function() { var u = navigator.userAgent, app = navigator.appVersion; return { trident: u.indexOf('Trident') > -1, presto: u.indexOf('Presto') > -1, webKit: u.indexOf('AppleWebKit') > -1, gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/), ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, iPad: u.indexOf('iPad') > -1, webApp: u.indexOf('Safari') == -1 }; }(), language: (navigator.browserLanguage || navigator.language).toLowerCase() } if (browser.versions.ios || browser.versions.iPhone || browser.versions.iPad) { window.location="https://itunes.apple.com/cn/app/xxx"; } else if (browser.versions.android) { window.location="http://zhj8.aliapp.com/xxx.apk"; }
</script> </head> <body> </body> </html>
|
本文来源:http://www.cnblogs.com/pengxl/p/3476588.html