PHP代码实现微信打开域名跳转浏览器已适配安卓和IOS系统

JS网页代码 2年前 (2019) Mgo
1
已经做了安卓和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{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>点击右上角<img src="//gw.alicdn.com/tfs/TB1xwiUNpXXXXaIXXXXXXXXXXXX-55-55.png" class="icon-safari" /> Safari打开</p>
  30. <p>可以继续访问本站哦~</p>
  31. </div>
  32. <a class="app-download-btn" id="BtnClick" href="javascript:;">
  33. 点此继续访问
  34. </a>
  35. <script>
  36. var url = 'http://www.92mo.cn/'; //填写要跳转到的网址
  37. document.querySelector('body').addEventListener('touchmove', function (event) {
  38. event.preventDefault();
  39. });
  40. window.mobileUtil = (function(win, doc) {
  41. var UA = navigator.userAgent,
  42. isAndroid = /android|adr/gi.test(UA),
  43. isIOS = /iphone|ipod|ipad/gi.test(UA) && !isAndroid,
  44. isBlackBerry = /BlackBerry/i.test(UA),
  45. isWindowPhone = /IEMobile/i.test(UA),
  46. isMobile = isAndroid || isIOS || isBlackBerry || isWindowPhone;
  47. return {
  48. isAndroid: isAndroid,
  49. isIOS: isIOS,
  50. isMobile: isMobile,
  51. isWeixin: /MicroMessenger/gi.test(UA),
  52. isQQ: /QQ/gi.test(UA)
  53. };
  54. })(window, document);
  55. if(mobileUtil.isWeixin){
  56. if(mobileUtil.isIOS){
  57. url = "https://t.asczwa.com/taobao?backurl=" + encodeURIComponent(url);
  58. document.getElementById('BtnClick').href=url;
  59. }else if(mobileUtil.isAndroid){
  60. url = '?open=1';
  61. document.getElementById('BtnClick').href=url;
  62. var iframe = document.createElement("iframe");
  63. iframe.style.display = "none";
  64. iframe.src = url;
  65. document.body.appendChild(iframe);
  66. }
  67. }else{
  68. document.getElementById('BtnClick').href=url;
  69. window.location.replace(url);
  70. }
  71. //setTimeout('WeixinJSBridge.invoke("closeWindow", {}, function(e) {})', 2000);
  72. </script>
  73. </body>
  74. </html>

版权声明:Mgo 发表于 2019-03-22 14:26:27。
转载请注明:PHP代码实现微信打开域名跳转浏览器已适配安卓和IOS系统 | 站长聚集地

1 条评论