微信浏览器中支持直接下载apk,通过跳转到应用宝

www.edusoho.com/download/mobile?client=android&code=edusoho

 <!DOCTYPE html>
 <html>
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <title>应用正在下载...</title>
 <style>
 .message {font-style: 12px; color: #444;}
 </style>
 </head>
  
 <body>
 <div id="message">正在载入数据...</div>
 </body>
  
  
 <script>
 var urls = {
 iphone: 'https://itunes.apple.com/cn/app/kuo-zhi-xue-tang/id887301045',
 android: 'http://download.edusoho.com/edusoho-android-2.3.3.apk',
 weixin: 'http://a.app.qq.com/o/simple.jsp?pkgname=' + 'com.edusoho.kuozhi',
 };
 var uagent = navigator.userAgent.toLowerCase();
 var href = window.location.href.toLowerCase();
 if (uagent.search("iphone") > -1 || uagent.search("ipad") > -1 || href.search("iphone") > -1 || href.search("ipad") > -1) {
 if (urls.iphone) {
 window.location = urls.iphone;
 } else {
 var messageNode = document.getElementById("message");
 messageNode.parentNode.removeChild(messageNode);
 document.write("<div class='message'>暂无iphone版本...</div>");
 }
 } else if(uagent.match(/MicroMessenger/i)=="micromessenger") {
 window.location = urls.weixin;
 } else {
 window.location = urls.android;
 }
 </script>
  
 </html>

这个网页里面的源码可以进行参考

相关推荐