js判断是否为微信浏览器【代码】

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/zhongyuchuan147/article/details/52105837
<html>
<head>
<title>测试</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<script type="text/javascript"> 
window.onload = function(){ 

function is_weixn(){  
var ua = navigator.userAgent.toLowerCase();  
if(ua.match(/MicroMessenger/i)=="micromessenger") {  
return true;  
} else {  
return false;  
}  
}  


if(is_weixn()){
alert('微信浏览器');
}else{
alert('其他');
}

</script>
</html>

猜你喜欢

转载自blog.csdn.net/zhongyuchuan147/article/details/52105837