根据不同的设备跳转到不同的url
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title></title> </head> <body> <script> /** 出来的链接大概是长这样的 http://xxxx.cn/243423.html?c=Q23DR32 */ // c=Q23DR32是注册时扫描获取的邀请码。 // 这样加参数,后面的参数会被自动忽略,不会影响加载此网页 goDownload(); /** * 去下载 */ function goDownload() { let u = navigator.userAgent, app = navigator.appVersion; let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // 是安卓浏览器 if (isAndroid) { window.location.href = 'https://fir.im/v5d9'; // 跳安卓端下载地址 } // 是iOS浏览器 if (isIOS) { window.location.href = 'https://itunes.apple.com/cn/app/%E8%A8%80%E6%99%BA%E5%8D%95%E8%BD%A6/id1411149932?mt=8'; // 跳AppStore下载地址 } // 是微信内部webView if (is_weixn()) { alert("请点击右上角按钮, 点击使用浏览器打开"); } // 是PC端 if (IsPC()) { window.location.href = 'http://www.aipxs.com/'; // 公司主页 } } /** * 是微信浏览器 */ function is_weixn() { let ua = navigator.userAgent.toLowerCase(); return ua.match(/MicroMessenger/i) === "micromessenger"; } /** * @return {boolean} */ function IsPC() { let userAgentInfo = navigator.userAgent; let Agents = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod"]; let flag = true; for (let v = 0; v < Agents.length; v++) { if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; } } return flag; } </script> </body> </html>