判断当前页面是否在微信浏览器中打开
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>判断当前页面是否在微信浏览器中打开</title>
<script type="text/javascript">
var ua = navigator.userAgent.toLowerCase();
var isWeixin = ua.indexOf('micromessenger') != -1;
console.log(isWeixin);
if (isWeixin) {
alert('你来到微信浏览器啦!');
}else{
alert('微信浏览器说它想你了什么时候回去啊?');
}
</script>
</head>
<body>
<h1>欢迎来到测试页面!</h1>
</body>
</html>