1. 程式人生 > >js判斷是否為微信瀏覽器【程式碼】

js判斷是否為微信瀏覽器【程式碼】

<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>