微信内置浏览器调起外部浏览器打开指定网页连接
2019-01-15 14:48
573 查看
此方法可以实现微信内置浏览器跳转到手机其它浏览器,现在网上其它的方法都只是一个页面,让访问者自己手动点右上角浏览器打开,而这个不同,是可以直接自动跳转的。
安卓访问时可以直接自动跳转浏览器;IOS 就复杂一点了,需要点一下然后借助手机淘宝才可以跳转。
下面是全部代码,已经做了安卓和 IOS 的适配。需要替换其中要跳转的网址,然后保存为 php 文件,在微信内访问即可实现自动跳转:
[code]<?php error_reporting(0); if($_GET['open']==1 && strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')!==false){ header("Content-Disposition: attachment; filename=\"load.doc\""); header("Content-Type: application/vnd.ms-word;charset=utf-8"); } ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Welcome</title> <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"/> <meta content="yes" name="apple-mobile-web-app-capable"/> <meta content="black" name="apple-mobile-web-app-status-bar-style"/> <meta name="format-detection" content="telephone=no"/> <meta content="false" name="twcClient" id="twcClient"/> <style> body,html{width:100%;height:100%} *{margin:0;padding:0} body{background-color:#fff} .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} .top-bar-guidance .icon-safari{width:25px;height:25px;vertical-align:middle;margin:0 .2em} .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} </style> </head> <body> <div class="top-bar-guidance"> <p>点击右上角<img src="//gw.alicdn.com/tfs/TB1xwiUNpXXXXaIXXXXXXXXXXXX-55-55.png" class="icon-safari" /> Safari 打开</p> <p>可以继续访问本站哦~</p> </div> <a class="app-download-btn" id="BtnClick" href="javascript:;"> 点此继续访问 </a> <script> var url = 'http://blog.cccyun.cc/'; //填写要<a href="https://www.mywlaq.cn/archives/tag/%e8%b7%b3%e8%bd%ac" title="查看更多关于跳转的文章" target="_blank">跳转</a>到的网址 document.querySelector('body').addEventListener('touchmove', function (event) { event.preventDefault(); }); window.mobileUtil = (function(win, doc) { var UA = navigator.userAgent, isAndroid = /android|adr/gi.test(UA), isIOS = /iphone|ipod|ipad/gi.test(UA) && !isAndroid, isBlackBerry = /BlackBerry/i.test(UA), isWindowPhone = /IEMobile/i.test(UA), isMobile = isAndroid || isIOS || isBlackBerry || isWindowPhone; return { isAndroid: isAndroid, isIOS: isIOS, isMobile: isMobile, isWeixin: /MicroMessenger/gi.test(UA), isQQ: /QQ/gi.test(UA) }; })(window, document); if(mobileUtil.isWeixin){ if(mobileUtil.isIOS){ url = "https://t.asczwa.com/taobao?backurl=" + encodeURIComponent(url); document.getElementById('BtnClick').href=url; }else if(mobileUtil.isAndroid){ url = '?open=1'; document.getElementById('BtnClick').href=url; var iframe = document.createElement("iframe"); iframe.style.display = "none"; iframe.src = url; document.body.appendChild(iframe); } }else{ document.getElementById('BtnClick').href=url; window.location.replace(url); } //setTimeout('WeixinJSBridge.invoke("closeWindow", {}, function(e) {})', 2000); </script> </body> </html>
相关文章推荐
- 微信中如何通过手机系统默认外部浏览器打开指定网页URL
- 微信点击链接跳转外部浏览器打开指定页面的实现
- 微信中安卓手机点击链接强制跳转默认浏览器打开指定网页
- 判断是否是在微信的内置浏览器里打开的网页
- python打开浏览器指定网页并填写内容---微信篇
- 微信跳转外部浏览器打开指定下载链接的代码实现
- 在微信网页中,实现微信通过菜单‘在浏览器中打开’跳转到指定的url
- 如何限制网页只能在微信内置浏览器中打开?
- webview内网页的连接内置打开,不用手机的浏览器打开;设置网页进度条progress
- 判断网页是否由微信内置浏览器打开
- windows 下开机启动项目并全屏打开浏览器进入指定网页
- Javascript限制网页只能在微信内置浏览器中访问
- 微信防封系统:手机浏览器或者QQ唤起微信打开指定链接
- Javascript限制网页只能在微信内置浏览器中访问
- C#使用默认浏览器打开指定网页
- 调用symbian 浏览器打开指定网页
- S60第三版上启动浏览器并打开指定网页
- PHP限制网页只能在微信内置浏览器中查看并显示
- android 调用默认浏览器 打开指定网页
- Javascript限制网页只能在微信内置浏览器中访问