如何检测已安装的Chrome版本? [英] How to detect the installed Chrome version?
本文介绍了如何检测已安装的Chrome版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发Chrome扩展程序,并且我想知道是否有一种方法可以检测到用户正在使用哪个版本的Chrome?
function getChromeVersion(){
var raw = navigator.userAgent.match(/ Chrom(e | ium)\ /([0-9] +)\。/);
返回原始数据? parseInt(raw [2],10):false;
}
我已更新原始答案,在其他浏览器中抛出异常,并且不使用已弃用的功能。
您还可以设置 minimum_chrome_version
在清单中不允许使用旧版本的用户安装它。
I'm developing a Chrome extension and I'm wondering is there a way that I can detect which version of Chrome the user is using?
解决方案
Get major version of Chrome as an integer:
function getChromeVersion () {
var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
return raw ? parseInt(raw[2], 10) : false;
}
I've updated the original answer, so that it does not throw an exception in other browsers, and does not use deprecated features.
You can also set minimum_chrome_version
in the manifest to not let users with older versions install it.
这篇关于如何检测已安装的Chrome版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文