# 检查浏览器版本工具函数

function checkBrowserVersion() {
  let chromeVersion = 0;
  
  if (navigator.userAgentData && navigator.userAgentData.brands) {
    // 现代浏览器支持的 `navigator.userAgentData`
    const brand = navigator.userAgentData.brands.find(b => b.brand === "Google Chrome" || b.brand === "Chromium");
    if (brand) {
      chromeVersion = parseInt(brand.version, 10);
    }
  } else {
    // 兼容老版本的 `navigator.userAgent`
    const match = navigator.userAgent.match(/Chrom(?:e|ium)\/(\d+)\./);
    if (match) {
      chromeVersion = parseInt(match[1], 10);
    }
  }

  if (chromeVersion > 0 && chromeVersion < 100) {
    alert("您的浏览器版本过低,正常使用浏览器内核 Chrome 需大于 100,建议更换为xxx浏览器访问。");
  }
}

checkBrowserVersion();
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23