判断是否是用微信打开、是否是用微信朋友圈打开
①判断是否是用微信打开
<script>
$(window).on("load",function(){
function is_weixin() {
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger") {
return true;
} else {
return false;
}
}
})
</script>
②判断是否是用微信朋友圈打开
方法一:
<script>
$(window).on("load",function(){
function isnot_weixin() {
var ua = navigator.userAgent.toLowerCase();
var wlocat=window.location;
var re = /timeline/;
if (!(ua.match(/MicroMessenger/i) == "micromessenger")||(re.test(wlocat)==false)) {
return true;
} else {
return false;
}
}
})
</script>
方法二:
<script>
$(window).on("load",function(){
function GetQueryString(name)
{
var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if(r!=null)return unescape(r[2]); return null;
}
function is_weixin() {
var ua = navigator.userAgent.toLowerCase();
var ga = GetQueryString("from");
if (ua.match(/MicroMessenger/i) == "micromessenger" && ga.match(/timeline/i) == "timeline") {
return true;
} else {
return false;
}
}
})
</script>
③判断如果不是用微信朋友圈打开的:
<script>
$(window).on("load",function(){
function isnot_weixin() {
var ua = navigator.userAgent.toLowerCase();
var wlocat=window.location;
var re = /timeline/;
if (!(ua.match(/MicroMessenger/i) == "micromessenger")||(re.test(wlocat)==false)) {
return true;
} else {
return false;
}
}
})
</script>