saber酱的抱枕

Fly me to the moon

03/9
06:29
软件

获取 Chrome 浏览器的版本号

刚才需要获取 Chrome 浏览器的版本号,写了个代码如下:

const agent = navigator.userAgent;
if (agent.includes('Chrome')) {
	let chrome_ver = parseInt(agent.match(/[\d.]+/gi)[5]);
	console.log(chrome_ver);
}

此代码在 Windows 上的 Chrome 84 里测试通过。

如果以后过的时间长了,再用的话就要先验证一下对不对了。

获取 Chrome 浏览器的版本号