<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>判断当前是否微信/QQ浏览器</title>
</head>
<body>
<script>
// 跳转提示
if (is_weixn_qq()) {
alert("是微信/QQ浏览器")
}else{
alert("不是微信/QQ浏览器")
}
function is_weixn_qq(){
// 判断当前是否微信/QQ浏览器
var ua = navigator.userAgent;
var isWeixin = !!/MicroMessenger/i.test(ua);
var isQQ = !!/QQ\//i.test(ua);
if(isWeixin||isQQ){
return true;
}
return false;
}
</script>
</body>
</html>
评论 (0)