怎么让你的网站在QQ微信打开的时候提示用浏览器打开代码
现在很多业务网站都加了微信QQ打开提示用浏览器打开,怕域名让封了,事实上逻辑很简单,在网站中加一个监控代码,监控是用微信QQ打开的网站还是用浏览器打开的网站,如下图
下面开始说代码,看仔细了,对小白来说可能有点小难,不会的可以联系昊天有偿部署到你的网站
1,先添加判断代码,判断是微信QQ打开的网站,代码如下
<?php
$conf['qqjump']=1;
if(strpos($_SERVER['HTTP_USER_AGENT'], 'QQ/')||strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger')!==false && $conf['qqjump']==1){
$siteurl='https://'.$_SERVER['SERVER_NAME'].':'.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
echo '代码区域';
exit;
}
?>
方案1
把以下代码放到你网站的首页文件index中
<!DOCTYPE html>
<html lang="zh_CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>在浏览器打开</title>
<style type="text/css">
* {margin:0;padding:0;}
a {text-decoration:none;}
img {max-width:100%;height:auto;}
.weixin-tip {display:none;position:fixed;left:0;top:0;bottom:0;background:rgba(0,0,0,0.8);filter:alpha(opacity=80);height:100%;width:100%;z-index:100;}
.weixin-tip p {text-align:center;margin-top:10%;padding:0 5%;}
</style>
</head>
<body>
<div class="weixin-tip">
<p><img src="//ae01.alicdn.com/kf/Hb05e015ac5c64958bb6bb387972b6d38z.png" alt="在浏览器打开" /></p>
</div>
<script type="text/javascript">
$(window).on("load",function(){
var winHeight = $(window).height();
function is_weixin() {
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger") {
return true;
} else {
return false;
}
}
var isWeixin = is_weixin();
if(isWeixin){
$(".weixin-tip").css("height",winHeight);
$(".weixin-tip").show();
}
})
</script>
</body>
</html>
方案2
把以下代码放到网站的全局文件中
<html>
<head>
<meta charset="UTF-8">
<title>请使用浏览器打开</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">
<meta name="aplus-touch" content="1">
<style>
body,html {width:100%;height:100%}
* {margin:0;padding:0}
body {background-color:#fff}
#contens {font-weight:bold;margin:-285px 0px 10px;text-align:center;font-size:18px;margin-bottom:125px;}
.top-bar-guidance {font-size:15px;color:#fff;height:70%;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}
</style>
</head>
<body>
<div class="top-bar-guidance">
<p>点击右上角<img src="//gw.alicdn.com/tfs/TB1xwiUNpXXXXaIXXXXXXXXXXXX-55-55.png" class="icon-safari"> <span id="openm">Safari打开</span></p>
<p>可以继续浏览本站哦~</p>
</div>
<div id="contens">
检测到您正在使用应用内置浏览器<br />
请切换到手机浏览器浏览-昊天博客!<br />
昊天博客www.htboke.com<br/>
</div>
</html>
方案3
<html>
<head>
<meta charset="UTF-8">
<title>请使用浏览器打开</title>
<meta http-equiv="refresh" content="0; url="https://c.pc.qq.com/middlem.html?pfurl=http://www.htboke.com/">
</head>
<body>
</body>
</html>
最后编辑时间为: 2020-04-11 20:40 星期六
本文由
飞鸟投林 创作,除注明转载/出处外,均为本站原创,转载前请务必署名