通过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);
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,同时也希望多多支持!