function getBrowserInfo() {
var agent = navigator.userAgent.toLowerCase();
var regStr_ie = /msie +;/gi;
//var regStr_ie = /msie [\d.]+;/gi;
var regStr_ff = /firefox+/gi;
//var regStr_ff = /firefox\/[\d.]+/gi;
var regStr_chrome = /chrome+/gi;
//var regStr_chrome = /chrome\/[\d.]+/gi;
var regStr_saf = /safari+/gi;
//var regStr_saf = /safari\/[\d.]+/gi;
var obj = '';
//IE
if (agent.indexOf("msie") > 0) {
obj = agent.match(regStr_ie);
}
//firefox
if (agent.indexOf("firefox") > 0) {
obj = agent.match(regStr_ff);
}
//Chrome
if (agent.indexOf("chrome") > 0) {
obj = agent.match(regStr_chrome);
}
//Safari
if (agent.indexOf("safari") > 0 && agent.indexOf("chrome") < 0) {
obj = agent.match(regStr_saf);
}
}
脚本检查浏览器及其版本
最新推荐文章于 2022-09-20 17:31:23 发布