当前位置:   article > 正文

web端判断当前chrome版本

web端判断当前chrome版本

// 获取用户代理字符串
const userAgent: string = navigator.userAgent;

// 检查用户代理字符串是否包含 "Chrome"
if (userAgent.indexOf("Chrome") !== -1) {
    // 如果包含 "Chrome",进一步检查版本号
    const chromeVersionMatches = userAgent.match(/Chrome\/(\S+)/);
    if (chromeVersionMatches && chromeVersionMatches.length > 1) {
        const chromeVersion: string = chromeVersionMatches[1];
        // 解析版本号
        const majorVersion: number = parseInt(chromeVersion.split('.')[0], 10);
        
        // 检查版本是否为 90
        if (majorVersion >= 90) {
            console.log("This is Chrome version 90 or higher.");
        } else {
            console.log("This is Chrome, but not version 90 or higher.");
        }
    }
} else {
    console.log("This is not Chrome.");
}
 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/340162
推荐阅读
相关标签
  

闽ICP备14008679号