当前位置:首页 > 应用技巧 > 正文内容

微信域名网址强制跳转至浏览器打开指定HTML网页

cuijijun9个月前 (07-14)应用技巧1515
  1. 此方法可以实现微信内置浏览器跳转到手机其它浏览器,现在网上其它的方法都只是一个页面,让访问者自己手动点右上角浏览器打开,而这个不同,是可以直接自动跳转的。

  2. 安卓访问时可以直接自动跳转浏览器;IOS就复杂一点了,需要点一下然后借助手机淘宝才可以跳转。

  3. 下面是全部代码,已经做了安卓和IOS的适配。需要替换其中要跳转的网址,然后保存为php文件,在微信内访问即可实现自动跳转:


  4. <?php

  5. error_reporting(0);

  6. if($_GET['open']==1 && strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')!==false){

  7. header("Content-Disposition: attachment; filename=\"load.doc\"");

  8. header("Content-Type: application/vnd.ms-word;charset=utf-8");

  9. }

  10. ?>

  11. <!DOCTYPE html>

  12. <html>

  13. <head>

  14. <meta charset="UTF-8">

  15. <title>Welcome</title>

  16. <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"/>

  17. <meta content="yes" name="apple-mobile-web-app-capable"/>

  18. <meta content="black" name="apple-mobile-web-app-status-bar-style"/>

  19. <meta name="format-detection" content="telephone=no"/>

  20. <meta content="false" name="twcClient" id="twcClient"/>

  21. <style>

  22. body,html{width:100%;height:100%}

  23. *{margin:0;padding:0}

  24. body{background-color:#fff}

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

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

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

  28. </style>

  29. </head>

  30. <body>

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

  32. <p>

  33. 点击右上角<img src="//gw.alicdn.com/tfs/TB1xwiUNpXXXXaIXXXXXXXXXXXX-55-55.png" class="icon-safari"/> Safari打开

  34. </p>

  35. <p>

  36. 可以继续访问本站哦~

  37. </p>

  38. </div>

  39. <a class="app-download-btn" id="BtnClick" href="javascript:;"> 点此继续访问 </a>

  40. <script>

  41. var url = 'http://www.youngxj.cn';//更改需要跳转的地址

  42. document.querySelector('body').addEventListener('touchmove', function (event) {

  43. event.preventDefault();

  44. });

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

  46. var UA = navigator.userAgent,

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

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

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

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

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

  52. return {

  53. isAndroid: isAndroid,

  54. isIOS: isIOS,

  55. isMobile: isMobile,

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

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

  58. };

  59. })(window, document);

  60. if(mobileUtil.isWeixin){

  61. if(mobileUtil.isIOS){

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

  63. document.getElementById('BtnClick').href=url;

  64. }else if(mobileUtil.isAndroid){

  65. url = '?open=1';

  66. document.getElementById('BtnClick').href=url;

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

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

  69. iframe.src = url;

  70. document.body.appendChild(iframe);

  71. }

  72. }else{

  73. document.getElementById('BtnClick').href=url;

  74. window.location.replace(url);

  75. }

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

  77. </body>

  78. </html>


扫描二维码推送至手机访问。

版权声明:本文由学技树发布,如需转载请注明出处。

本文链接:http://www.xuejis.com/?id=10

分享给朋友:

“微信域名网址强制跳转至浏览器打开指定HTML网页” 的相关文章

小鱼儿yr系统重装助手

此工具主要用于方便一键安装本人封装的小鱼儿yr系统镜像。不要问我这个工具有没有捆绑,纯不纯净,我只能告诉你,用这个工具装完后的效果和直接在本站手动下载镜像然后手动进纯净PE里安装的效果一模一样。唯一的区别在于一个是一键完成,一个是经过很多复杂的手动操作才能完成,让系统重装化繁为简,节约时间,腾出手脚...

微信文件传输助手网页版

微信文件传输助手网页版是微信发布的一个网页版工具,它独立于微信网页版,提取了文件传输助手作为唯一功能,可以非常方便的在手机电脑间互传文件访问地址:https://filehelper.weixin.qq.com访问地址:https://szfilehelper.weixin.qq.com...

迅雷云盘获取直链

这是一个油猴脚本,安装以后可以获取迅雷云盘下载直链,可利用本地播放器看视频,可以让用户可以利用其他工具下载(如idm,curl,Xdown,Motrix,Aria2)。脚本没有任何加速下载功能,只是改变下载或播放方式!访问地址:https://greasyfork.org/zh-CN/scripts...

视频解析下载站

视频解析下载站,支持YouTube,抖音,Instagram,Twitter 等网站,具体自测!访问地址:https://v.hi.sy...

英文缩略词查询

这个网站可以在线查询英文缩略词的含义,输入缩略词就会展示该缩略词所代表的所有含义,十分方便!访问地址:https://www.abbreviationfinder.org...

淘宝评论生成器

淘宝买完东西不想评论,但是又舍不得评论积分,来试试这个万能淘宝评论生成器,解决烦恼!访问地址:https://haoduck.com/demo/tbpl.html...