温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

JS如何实现在微信中调用外部浏览器打开指定链接

发布时间:2020-03-02 18:04:16 来源:网络 阅读:390 作者:在我心里没 栏目:移动开发

使用方法,复制以下贴到index.php 顶部就可以了.
场景 比如网页包含视频播放  在QQ\WX打开QQ\WX直接调用自己的播放器播放,而且播放完成还有AD推送,非常恶心,所以有了以下代码有乱码的话说明你网页是GBK  自行转换下


JS如何实现在微信中调用外部浏览器打开指定链接

<?php
function qqwx(){ 
    if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) {
echo '<!DOCTYPE html>
<html>
  <head>
      <meta http-equiv="Content-Language" content="zh-CN">
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0" />
    <meta content="telephone=no" name="format-detection" />
 
    <title>提示</title>
    
    <style>
        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,h2,h3,h4,h5,h6,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}
 
        body{
            color:#222;
            font-size: 12px;
            padding: 120px 15px 20px;
            text-align:center;
        }
        h4{ 
            font-size: 18px; 
            font-weight: normal;
            margin-bottom: 13px;
        }
        .url{
            padding: 5px 0;
            word-break:break-all;
        }
    </style>
  </head>
  <body url="http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'">
    <div class="">
        <h4>请长按网址复制后使用浏览器访问</h4>
        <div id="url" class="url"></div>
    </div>
    <script>
        var text = document.createTextNode(document.body.getAttribute("url").replace(/&/g, "&"));
        document.getElementById("url").appendChild(text);
    </script>
  </body>
</html>';
exit();     }    
        if ( strpos($_SERVER['HTTP_USER_AGENT'], 'QQ/') !== false ) {
echo '<!DOCTYPE html>
<html>
  <head>
  
    <script src="https://open.mobile.qq.com/sdk/qqapi.js?_bid=152"></script>
  <script type="text/javascript"> mqq.ui.openUrl({ target: 2,url: "http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'"}); </script>
    <meta http-equiv="Content-Language" content="zh-CN">
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0" />
    <meta content="telephone=no" name="format-detection" />
 
    <title>提示</title>
    
    <style>
        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,h2,h3,h4,h5,h6,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}
 
        body{
            color:#222;
            font-size: 12px;
            padding: 120px 15px 20px;
            text-align:center;
        }
        h4{ 
            font-size: 18px; 
            font-weight: normal;
            margin-bottom: 13px;
        }
        .url{
            padding: 5px 0;
            word-break:break-all;
        }
    </style>
  </head>
  <body url="http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'">
    <div class="">
        <h4>如需浏览,请长按网址复制后使用浏览器访问</h4>
        <div id="url" class="url"></div>
    </div>
    <script>
        var text = document.createTextNode(document.body.getAttribute("url").replace(/&/g, "&"));
        document.getElementById("url").appendChild(text);
    </script>
  </body>
</html>';
exit();
    }  
}
qqwx();
?<?php
function qqwx(){ 
    if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false ) {
echo '<!DOCTYPE html>
<html>
  <head>
      <meta http-equiv="Content-Language" content="zh-CN">
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0" />
    <meta content="telephone=no" name="format-detection" />
 
    <title>提示</title>
    
    <style>
        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,h2,h3,h4,h5,h6,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}
 
        body{
            color:#222;
            font-size: 12px;
            padding: 120px 15px 20px;
            text-align:center;
        }
        h4{ 
            font-size: 18px; 
            font-weight: normal;
            margin-bottom: 13px;
        }
        .url{
            padding: 5px 0;
            word-break:break-all;
        }
    </style>
  </head>
  <body url="http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'">
    <div class="">
        <h4>请长按网址复制后使用浏览器访问</h4>
        <div id="url" class="url"></div>
    </div>
    <script>
        var text = document.createTextNode(document.body.getAttribute("url").replace(/&/g, "&"));
        document.getElementById("url").appendChild(text);
    </script>
  </body>
</html>';
exit();     }    
        if ( strpos($_SERVER['HTTP_USER_AGENT'], 'QQ/') !== false ) {
echo '<!DOCTYPE html>
<html>
  <head>
  
    <script src="https://open.mobile.qq.com/sdk/qqapi.js?_bid=152"></script>
  <script type="text/javascript"> mqq.ui.openUrl({ target: 2,url: "http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'"}); </script>
    <meta http-equiv="Content-Language" content="zh-CN">
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0" />
    <meta content="telephone=no" name="format-detection" />
 
    <title>提示</title>
    
    <style>
        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,h2,h3,h4,h5,h6,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}
 
        body{
            color:#222;
            font-size: 12px;
            padding: 120px 15px 20px;
            text-align:center;
        }
        h4{ 
            font-size: 18px; 
            font-weight: normal;
            margin-bottom: 13px;
        }
        .url{
            padding: 5px 0;
            word-break:break-all;
        }
    </style>
  </head>
  <body url="http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'">
    <div class="">
        <h4>如需浏览,请长按网址复制后使用浏览器访问</h4>
        <div id="url" class="url"></div>
    </div>
    <script>
        var text = document.createTextNode(document.body.getAttribute("url").replace(/&/g, "&"));
        document.getElementById("url").appendChild(text);
    </script>
  </body>
</html>';
exit();
    }  
}
qqwx();
<http://www.getinstall.cn/>



向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI