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

时间:2019-02-16 15:37:55   收藏:0   阅读:316

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

 

 

技术图片

 

 

 

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

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

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!