判断当前是否微信/QQ浏览器

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

我的个人博客 https://blog.52ipc.top/

posted @ 2022-08-10 17:14  Micky233  阅读(190)  评论(0编辑  收藏  举报