[综合教程] 微信/QQ内置浏览器打开网页跳转到系统浏览器[PHP]

[复制链接]
汇客网络 发表于 2019-6-30 18:54:42 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
  之前需要简单拼凑了以下代码,上CDN后无法使用!!!(CDN设置了缓存HTML,会错乱),现在存档!
  使用方法,复制以下贴到index.php 顶部就可以了.
  场景 比如网页包含视频播放  在QQWX打开QQWX直接调用自己的播放器播放,而且播放完成还有AD推送,非常恶心,所以有了以下代码有乱码的话说明你网页是GBK  自行转换下
  如果不会联系我 我帮你   我有时间的话
  1. <?php
  2. function qqwx(){
  3.     if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) {
  4. echo '<!DOCTYPE html>
  5. <html>
  6.   <head>
  7.       <meta http-equiv="Content-Language" content="zh-CN">
  8.     <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  9.     <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0" />
  10.     <meta content="telephone=no" name="format-detection" />

  11.     <title>提示</title>
  12.    
  13.     <style>
  14.         html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{line-height:1.6;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:16px}body,h1,h2,h3,h4,h5,p,ul,ol,dl,dd,fieldset,textarea{margin:0}fieldset,legend,textarea,input,button{padding:0}button,input,select,textarea{font-family:inherit;font-size:100%;margin:0;*font-family:"Helvetica Neue",Helvetica,Arial,sans-serif}ul,ol{padding-left:0;list-style-type:none;list-style-position:inside}a img,fieldset{border:0}a{text-decoration:none}

  15.         body{
  16.             color:#222;
  17.             font-size: 12px;
  18.             padding: 120px 15px 20px;
  19.             text-align:center;
  20.         }
  21.         h3{
  22.             font-size: 18px;
  23.             font-weight: normal;
  24.             margin-bottom: 13px;
  25.         }
  26.         .url{
  27.             padding: 5px 0;
  28.             word-break:break-all;
  29.         }
  30.     </style>
  31.   </head>
  32.   <body url="http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'">
  33.     <div class="">
  34.         <h3>请长按网址复制后使用浏览器访问</h3>
  35.         <div id="url" class="url"></div>
  36.     </div>
  37.     <script>
  38.         var text = document.createTextNode(document.body.getAttribute("url").replace(/&/g, "&"));
  39.         document.getElementById("url").appendChild(text);
  40.     </script>
  41.   </body>
  42. </html>';
  43. exit();     }   
  44.         if ( strpos($_SERVER['HTTP_USER_AGENT'], 'QQ/') !== false ) {
  45. echo '<!DOCTYPE html>
  46. <html>
  47.   <head>
  48.   
  49.     <script src="https://open.mobile.qq.com/sdk/qqapi.js?_bid=152"></script>
  50.   <script type="text/javascript"> mqq.ui.openUrl({ target: 2,url: "http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'"}); </script>
  51.     <meta http-equiv="Content-Language" content="zh-CN">
  52.     <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  53.     <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0" />
  54.     <meta content="telephone=no" name="format-detection" />

  55.     <title>提示</title>
  56.    
  57.     <style>
  58.         html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{line-height:1.6;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:16px}body,h1,h2,h3,h4,h5,p,ul,ol,dl,dd,fieldset,textarea{margin:0}fieldset,legend,textarea,input,button{padding:0}button,input,select,textarea{font-family:inherit;font-size:100%;margin:0;*font-family:"Helvetica Neue",Helvetica,Arial,sans-serif}ul,ol{padding-left:0;list-style-type:none;list-style-position:inside}a img,fieldset{border:0}a{text-decoration:none}

  59.         body{
  60.             color:#222;
  61.             font-size: 12px;
  62.             padding: 120px 15px 20px;
  63.             text-align:center;
  64.         }
  65.         h3{
  66.             font-size: 18px;
  67.             font-weight: normal;
  68.             margin-bottom: 13px;
  69.         }
  70.         .url{
  71.             padding: 5px 0;
  72.             word-break:break-all;
  73.         }
  74.     </style>
  75.   </head>
  76.   <body url="http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'">
  77.     <div class="">
  78.         <h3>如需浏览,请长按网址复制后使用浏览器访问</h3>
  79.         <div id="url" class="url"></div>
  80.     </div>
  81.     <script>
  82.         var text = document.createTextNode(document.body.getAttribute("url").replace(/&/g, "&"));
  83.         document.getElementById("url").appendChild(text);
  84.     </script>
  85.   </body>
  86. </html>';
  87. exit();
  88.     }  
  89. }
  90. qqwx();
  91. ?>
复制代码

抓头源码!一个免费分享源码的地方!
版权申明:资源所有权归属原创作者所有,本站仅提供交流学习之用,切勿用于商业用途 本贴地址:http://cf4.top/thread-2518-1-1.html 上篇帖子: 网站SEO优化与网站SEO赚钱秘籍 下篇帖子: 五大技巧,让你的电商网站SEO排名更靠前! 微信 内置 浏览 浏览器 打开
回复 关闭延时

使用道具 举报

高级模式
B Color Image Link Quote Code Smilies

本版积分规则

关注0

粉丝0

帖子4607

发布主题
广而告之
抓头网--专业精品商业源码分享
官网QQ群

211253332

周一至周日9:00-23:00

反馈建议

414778833@qq.com 在线QQ咨询

我们一直在用心服务

© 2001-2020 技术文章分享 版权所有工业信息产业部ICP备案号: 浙ICP备2023041498号-2

|网站地图|网站地图