一些做微信營(yíng)銷活動(dòng)或者需要推廣下載apk文件的域名經(jīng)常會(huì)紅,也就是域名被封了,微信屏蔽訪問(wèn)了!
如圖:
而微信屏蔽的原理主要應(yīng)該有兩條:
第一是系統(tǒng)的自動(dòng)檢測(cè)
第二是微信工作人員的人工檢測(cè)
至于我們防止屏蔽通常也有兩種方法:(通過(guò)屏蔽和監(jiān)測(cè)一些騰訊的監(jiān)測(cè)IP等。從而避免系統(tǒng)的查殺。保證鏈接在微信和QQ中一直可以直接打開。不用擔(dān)心被封禁從而無(wú)法打開的情況!!)1、彈框提示法,這種事最簡(jiǎn)單的方法。方式如下圖(適用于下載,違規(guī)網(wǎng)址打開
這個(gè)其實(shí)就是通過(guò)判斷是否是微信瀏覽器而實(shí)現(xiàn)的,如果是微信的瀏覽器就彈出模態(tài)框圖片提示用戶跳去瀏覽器
下面分享下邵先森使用的源代碼:
你的標(biāo)題
/*演示用,請(qǐng)勿引入項(xiàng)目中*/
*{margin:0; padding: 0;}
body{font:normal 14px/1.5 Arial,Microsoft Yahei; color:#333;}
.example{padding: 20px;}
.example p{margin: 20px 0;}
a{display: inline-block; background: #61B3E6; color:#fff; padding: 0 15px; border-radius: 6px; text-align: center;
margin: 0 8px; line-height: 25px; font-size: 20px; text-decoration: none;}
a.btn-warn{background: #F0AD4E;}
a:hover{opacity: 0.8;}
/*核心css*/
.wxtip{background: rgba(0,0,0,0.8); text-align: center; position: fixed; left:0; top: 0; width: 100%;
height: 100%; z-index: 998; display: none;}
.wxtip-icon{width: 52px; height: 67px; background: url(http://img.caibaojian.com/uploads/2016/01/weixin-
tip.png) no-repeat; display: block; position: absolute; right: 30px; top: 20px;}
.wxtip-txt{padding-top: 107px; color: #fff; font-size: 16px; line-height: 1.5;}
歡迎來(lái)到澤以自助下單業(yè)務(wù)平臺(tái)-用心創(chuàng)造快樂(lè) 因微信官方屏蔽,請(qǐng)用手機(jī)瀏覽器訪問(wèn),謝謝!
點(diǎn)擊進(jìn)入①號(hào)下單平臺(tái)
點(diǎn)擊進(jìn)入②號(hào)下單平臺(tái)
點(diǎn)擊右上角選擇在瀏覽器中打開
function weixinTip(ele){
var ua = navigator.userAgent;
var isWeixin = !!/MicroMessenger/i.test(ua);
if(isWeixin){
ele.onclick=function(e){
window.event? window.event.returnValue = false : e.preventDefault();
document.getElementById('JweixinTip').style.display='block';
}
document.getElementById('JweixinTip').onclick=function(){
this.style.display='none';
}
}
}
var btn1 = document.getElementById('YUEZEYI1');//1
weixinTip(btn1);
var btn2 = document.getElementById('YUEZEYI2'); //2
weixinTip(btn2);
判斷那種系統(tǒng)而強(qiáng)制手機(jī)端打開:
這種方法不僅可以實(shí)現(xiàn)微信端打開提示使用手機(jī)默認(rèn)瀏覽器而且會(huì)判斷是那種系統(tǒng)而去強(qiáng)制某種系統(tǒng)打開!
下面代碼轉(zhuǎn)自大傻逼-原文連接:https://www.cnblogs.com/s-b-b/p/5822819.html
實(shí)現(xiàn)思路:
1.在頁(yè)面加載的時(shí)候去判斷是否在微信瀏覽器里面,如果是就彈出模態(tài)框圖片提示用戶跳去瀏覽器下載
var ua = navigator.userAgent.toLowerCase();//獲取判斷用的對(duì)象
if (ua.match(/MicroMessenger/i) == "micromessenger") { // 彈出模態(tài)框提示用戶
document.getElementById('download-modal').style.visibility = "visible";
}2.判斷是否哪種系統(tǒng)(android,ios)
最后附上源代碼:// 判斷系統(tǒng)客戶端
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android終端
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios終端
if(isAndroid == true){ // alert('Android!');
window.location = 'android.apk';
} else { if(isiOS == true){ // alert('ios!');
window.location = 'https://itunes.apple.com/';
}else{
alert('請(qǐng)?jiān)谑謾C(jī)端打開');
}
}最后附上源代碼:
<script type="text/javascript">
function down(){
// 判斷是否微信瀏覽器
var ua = navigator.userAgent.toLowerCase();//獲取判斷用的對(duì)象
if (ua.match(/MicroMessenger/i) == "micromessenger") {
// 彈出模態(tài)框提示用戶
document.getElementById('download-modal').style.visibility = "visible";
}else{
// 判斷系統(tǒng)客戶端
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android終端
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios終端
if(isAndroid == true){
// alert('Android!');
window.location = 'litme.apk';
}
else {
if(isiOS == true){
// alert('ios!');
window.location = 'https://itunes.apple.com/';
}else{
alert('請(qǐng)?jiān)谑謾C(jī)端打開');
}
}
}
}
function closeModal(){
var modal = document.getElementById('download-modal');
modal.style.visibility = "hidden";
}
.download-modal{
visibility: hidden;
width: 100%;
height: 100%;
opacity: 0.5;
position: absolute;
text-align: center;
background-color:rgb(30,30,30);
top: 0;
left: 0;
z-index: 9999;
}
.download-modal-mess{
}
#jump-to-browser{
width: 90%;
}
步驚云