1. 程式人生 > >QQ微信域名防封 預防域名封禁 微信強制跳轉至瀏覽器打開

QQ微信域名防封 預防域名封禁 微信強制跳轉至瀏覽器打開

body html 自動 .html word mobile nco 內置瀏覽器 瀏覽器

此方法可以實現微信內置瀏覽器跳轉到手機其它瀏覽器,現在網上其它的方法都只是一個頁面,讓訪問者自己手動點右上角瀏覽器打開,而這個不同,是可以直接自動跳轉的。

技術分享圖片

已經做了安卓和IOS的適配。需要替換其中要跳轉的網址,然後保存為php文件,在微信內訪問即可實現自動跳轉:

 
  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{ outline: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; margin: 8px 0px 0px 40px; list-style-type: decimal; word-wrap: break-word;">

    .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}

  22. .top-bar-guidance .icon-safari{width:25px;height:25px;vertical-align:middle;margin:0 .2em}

  23. .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}

  24. </style>

  25. </head>

  26. <body>

  27. <div class="top-bar-guidance">

  28. <p>

  29. 點擊右上角<img src="//gw.alicdn.com/tfs/TB1xwiUNpXXXXaIXXXXXXXXXXXX-55-55.png" class="icon-safari"/> Safari打開

  30. </p>

  31. <p>

  32. 可以繼續訪問本站哦~

  33. </p>

  34. </div>

  35. <a class="app-download-btn" id="BtnClick" href="javascript:;"> 點此繼續訪問 </a>

  36. <script>

  37. var url = ‘http://www.youngxj.cn‘;//更改需要跳轉的地址

  38. document.querySelector(‘body‘).addEventListener(‘touchmove‘, function (event) {

  39. event.preventDefault();

  40. });

  41. window.mobileUtil = (function(win, doc) {

  42. var UA = navigator.userAgent,

  43. isAndroid = /android|adr/gi.test(UA),

  44. isIOS = /iphone|ipod|ipad/gi.test(UA) && !isAndroid,

  45. isBlackBerry = /BlackBerry/i.test(UA),

  46. isWindowPhone = /IEMobile/i.test(UA),

  47. isMobile = isAndroid || isIOS || isBlackBerry || isWindowPhone;

  48. return {

  49. isAndroid: isAndroid,

  50. isIOS: isIOS,

  51. isMobile: isMobile,

  52. isWeixin: /MicroMessenger/gi.test(UA),

  53. isQQ: /QQ/gi.test(UA)

  54. };

  55. })(window, document);

  56. if(mobileUtil.isWeixin){

  57. if(mobileUtil.isIOS){

  58. url = "https://t.asczwa.com/taobao?backurl=" + encodeURIComponent(url);

  59. document.getElementById(‘BtnClick‘).href=url;

  60. }else if(mobileUtil.isAndroid){

  61. url = ‘?open=1‘;

  62. document.getElementById(‘BtnClick‘).href=url;

  63. var iframe = document.createElement("iframe");

  64. iframe.style.display = "none";

  65. iframe.src = url;

  66. document.body.appendChild(iframe);

  67. }

  68. }else{

  69. document.getElementById(‘BtnClick‘).href=url;

  70. window.location.replace(url);

  71. }

  72. //setTimeout(‘WeixinJSBridge.invoke("closeWindow", {}, function(e) {})‘, 2000); </script>

  73. </body>

  74. </html>

跳轉域名需要備案,具體自行測試

QQ微信域名防封 預防域名封禁 微信強制跳轉至瀏覽器打開