微信为什么不能下载apk 微信不能打开App下载地址的问题

时间:2023-12-24 11:55:01

此方法可以实现微信内置浏览器跳转到手机其它浏览器,现在网上其它的方法都只是一个页面,让访问者自己手动点右上角浏览器打开,而这个不同,是可以直接自动跳转的。

微信为什么不能下载apk 微信不能打开App下载地址的问题

  1. <?php
  2. error_reporting(0);
  3. if($_GET['open']==1 && strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')!==false){
  4. header("Content-Disposition: attachment; filename=\"load.doc\"");
  5. header("Content-Type: application/vnd.ms-word;charset=utf-8");
  6. }
  7. ?>
  8. <!DOCTYPE html>
  9. <html>
  10. <head>
  11. <meta charset="UTF-8">
  12. <title>Welcome</title>
  13. <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"/>
  14. <meta content="yes" name="apple-mobile-web-app-capable"/>
  15. <meta content="black" name="apple-mobile-web-app-status-bar-style"/>
  16. <meta name="format-detection" content="telephone=no"/>
  17. <meta content="false" name="twcClient" id="twcClient"/>
  18. <style>
  19. body,html{width:100%;height:100%}
  20. *{margin:0;padding:0}
  21. body{background-color:#fff}
  22. .top-bar-guidance{font-size:15px;color:#fff;height:40%;line-height:1.8;padding-left:20px;padding-top:20px;background:url(//gw.alicdn.com/tfs/TB1eSZaNFXXXXb.XXXXXXXXXXXX-750-234.png) center top/contain no-repeat}
  23. .top-bar-guidance .icon-safari{width:25px;height:25px;vertical-align:middle;margin:0 .2em}
  24. .app-download-btn{display:block;width:214px;height:40px;line-height:40px;margin:18px auto 0 auto;text-align:center;font-size:18px;color:#2466f4;border-radius:20px;border:.5px #2466f4 solid;text-decoration:none}
  25. </style>
  26. </head>
  27. <body>
  28. <div class="top-bar-guidance">
  29. <p>
  30. 点击右上角<img src="//gw.alicdn.com/tfs/TB1xwiUNpXXXXaIXXXXXXXXXXXX-55-55.png" class="icon-safari"/> Safari打开
  31. </p>
  32. <p>
  33. 可以继续访问本站哦~
  34. </p>
  35. </div>
  36. <a class="app-download-btn" id="BtnClick" href="javascript:;"> 点此继续访问 </a>
  37. <script>
  38. var url = 'http://www.youngxj.cn';//更改需要跳转的地址
  39. document.querySelector('body').addEventListener('touchmove', function (event) {
  40. event.preventDefault();
  41. });
  42. window.mobileUtil = (function(win, doc) {
  43. var UA = navigator.userAgent,
  44. isAndroid = /android|adr/gi.test(UA),
  45. isIOS = /iphone|ipod|ipad/gi.test(UA) && !isAndroid,
  46. isBlackBerry = /BlackBerry/i.test(UA),
  47. isWindowPhone = /IEMobile/i.test(UA),
  48. isMobile = isAndroid || isIOS || isBlackBerry || isWindowPhone;
  49. return {
  50. isAndroid: isAndroid,
  51. isIOS: isIOS,
  52. isMobile: isMobile,
  53. isWeixin: /MicroMessenger/gi.test(UA),
  54. isQQ: /QQ/gi.test(UA)
  55. };
  56. })(window, document);
  57. if(mobileUtil.isWeixin){
  58. if(mobileUtil.isIOS){
  59. url = "https://t.asczwa.com/taobao?backurl=" + encodeURIComponent(url);
  60. document.getElementById('BtnClick').href=url;
  61. }else if(mobileUtil.isAndroid){
  62. url = '?open=1';
  63. document.getElementById('BtnClick').href=url;
  64. var iframe = document.createElement("iframe");
  65. iframe.style.display = "none";
  66. iframe.src = url;
  67. document.body.appendChild(iframe);
  68. }
  69. }else{
  70. document.getElementById('BtnClick').href=url;
  71. window.location.replace(url);
  72. }
  73. //setTimeout('WeixinJSBridge.invoke("closeWindow", {}, function(e) {})', 2000); </script>
  74. </body>
  75. </html>

跳转域名需要备案,具体自行测试