JavaScript判断浏览器及其版本信息_优就业

时间:2021-11-17 14:51:50

JavaScript判断浏览器及其版本信息

JavaScript判断浏览器及其版本信息_优就业

Web前端:www.ujiuye.com/

通过window.navigator来判断:

function getBrowserInfo(){

var Info = {};

var str = window.navigator.userAgent.toLowerCase();

var bReg =/(msie|firefox|chrome|opera|version).*?([\d.]+)/;

var infoArr = str.match(bReg);

Info.browser = infoArr[1].replace(/version/, "safari");

Info.ver = infoArr[2];

return Info;

}

var BomInfo = getBrowserInfo();

document.write(BomInfo.browser);

document.write("</br>");

document.write(BomInfo.ver);

更多Web前端知识尽在优就业IT培训:www.ujiuye.com/