你怎么能检测浏览器的版本?
我一直在寻找代码,可以让我检测访问该网站的用户是否有Firefox 3或4.我发现的所有代码是检测浏览器的types,而不是版本。
我怎样才能检测到这样的浏览器的版本?
您可以看到浏览器所说的内容 ,并将这些信息用于logging或testing多个浏览器。
navigator.sayswho= (function(){ var ua= navigator.userAgent, tem, M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; if(/trident/i.test(M[1])){ tem= /\brv[ :]+(\d+)/g.exec(ua) || []; return 'IE '+(tem[1] || ''); } if(M[1]=== 'Chrome'){ tem= ua.match(/\b(OPR|Edge)\/(\d+)/); if(tem!= null) return tem.slice(1).join(' ').replace('OPR', 'Opera'); } M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?']; if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]); return M.join(' '); })(); console.log(navigator.sayswho);
这是对肯尼贝克答案的改进。
function get_browser() { var ua=navigator.userAgent,tem,M=ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; if(/trident/i.test(M[1])){ tem=/\brv[ :]+(\d+)/g.exec(ua) || []; return {name:'IE',version:(tem[1]||'')}; } if(M[1]==='Chrome'){ tem=ua.match(/\bOPR|Edge\/(\d+)/) if(tem!=null) {return {name:'Opera', version:tem[1]};} } M=M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?']; if((tem=ua.match(/version\/(\d+)/i))!=null) {M.splice(1,1,tem[1]);} return { name: M[0], version: M[1] }; }
然后你运行:
var browser=get_browser(); // browser.name = 'Chrome' // browser.version = '40'
通过这种方式,您可以避免代码的模糊。
这结合肯尼贝克(K)答案和赫尔曼Ingjaldsson的(H)答案:
- 保持原始答案的最小代码。 (K)
- 与Microsoft Edge(K)合作
- 扩展导航器对象,而不是创build一个新的variables/对象。 (K)
- 将浏览器版本和名称分离为独立的子对象。 (H)
navigator.browserSpecs = (function(){ var ua= navigator.userAgent, tem, M= ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; if(/trident/i.test(M[1])){ tem= /\brv[ :]+(\d+)/g.exec(ua) || []; return {name:'IE',version:(tem[1] || '')}; } if(M[1]=== 'Chrome'){ tem= ua.match(/\b(OPR|Edge)\/(\d+)/); if(tem!= null) return {name:tem[1].replace('OPR', 'Opera'),version:tem[2]}; } M= M[2]? [M[1], M[2]]: [navigator.appName, navigator.appVersion, '-?']; if((tem= ua.match(/version\/(\d+)/i))!= null) M.splice(1, 1, tem[1]); return {name:M[0],version:M[1]}; })(); console.log(navigator.browserSpecs); //Object { name: "Firefox", version: "42" } if (navigator.browserSpecs.name == 'Firefox') { // Do something for Firefox. if (navigator.browserSpecs.version > 42) { // Do something for Firefox versions greater than 42. } } else { // Do something for all other browsers. }
使用这个: http : //www.quirksmode.org/js/detect.html
alert(BrowserDetect.browser); // will say "Firefox" alert(BrowserDetect.version); // will say "3" or "4"
我正在为自己寻找一个解决scheme,因为jQuery 1.9.1及以上版本已经删除了$.browser
function。 我想出了这个适合我的小function。 它确实需要一个全局variables(我称之为mine _browser)来检查它是哪个浏览器。 我已经写了一个jsfiddle来说明如何使用它,当然它可以通过添加一个testing_browser.foo,其中foo是浏览器的名称扩展其他浏览器。 我做的只是stream行的。
detectBrowser()
_browser = {}; function detectBrowser() { var uagent = navigator.userAgent.toLowerCase(), match = ''; _browser.chrome = /webkit/.test(uagent) && /chrome/.test(uagent) && !/edge/.test(uagent); _browser.firefox = /mozilla/.test(uagent) && /firefox/.test(uagent); _browser.msie = /msie/.test(uagent) || /trident/.test(uagent) || /edge/.test(uagent); _browser.safari = /safari/.test(uagent) && /applewebkit/.test(uagent) && !/chrome/.test(uagent); _browser.opr = /mozilla/.test(uagent) && /applewebkit/.test(uagent) && /chrome/.test(uagent) && /safari/.test(uagent) && /opr/.test(uagent); _browser.version = ''; for (x in _browser) { if (_browser[x]) { match = uagent.match( new RegExp("(" + (x === "msie" ? "msie|edge" : x) + ")( |\/)([0-9]+)") ); if (match) { _browser.version = match[3]; } else { match = uagent.match(new RegExp("rv:([0-9]+)")); _browser.version = match ? match[1] : ""; } break; } } _browser.opera = _browser.opr; delete _browser.opr; }
要检查当前的浏览器是否是Opera,你会这样做
if (_browser.opera) { // Opera specific code }
编辑修正了格式化,修复了IE11和Opera / Chrome的检测,由result改为browserResult。 现在, _browser
键的顺序并不重要。 更新了jsFiddle链接。
2015/08/11 编辑添加新的Internet Explorer 12(EDGE)的testing用例,修复了一个小的正则expression式问题。 更新了jsFiddle链接。
function BrowserCheck() { var N= navigator.appName, ua= navigator.userAgent, tem; var M= ua.match(/(opera|chrome|safari|firefox|msie|trident)\/?\s*(\.?\d+(\.\d+)*)/i); if(M && (tem= ua.match(/version\/([\.\d]+)/i))!= null) {M[2]=tem[1];} M= M? [M[1], M[2]]: [N, navigator.appVersion,'-?']; return M; }
这将返回一个数组,第一个元素是浏览器名称,第二个元素是string格式的完整版本号。
bowser JavaScript库提供了这个function。
if (bowser.msie && bowser.version <= 6) { alert('Hello China'); }
这似乎是很好的维护。
jQuery可以处理这个相当不错的( jQuery.browser )
var ua = $.browser; if ( ua.mozilla && ua.version.slice(0,3) == "1.9" ) { alert( "Do stuff for firefox 3" ); }
编辑:正如约书亚在他的评论中写道, jQuery.browser属性不再支持jQuery自1.9版本(阅读jQuery 1.9发行说明了解更多详情)。 jQuery开发团队build议使用更完整的方法,如使用Modernizr库来调整UI。
在纯Javascript中,您可以在navigator.userAgent
上执行RegExp匹配以查找Firefox版本:
var uMatch = navigator.userAgent.match(/Firefox\/(.*)$/), ffVersion; if (uMatch && uMatch.length > 1) { ffVersion = uMatch[1]; }
如果不是Firefox浏览器,则ffVersion
将是undefined
。
见工作示例→
看navigator.userAgent
– 最后指定Firefox/xxx.xxx.xxx
。
我已经在ASP代码中编写脚本来检测浏览器,浏览器版本,操作系统和操作系统版本。 我在ASP中这样做的原因是因为我想将数据存储在日志数据库中。 所以我必须检测浏览器的服务器端。
这里是代码:
on error resume next ua = lcase(Request.ServerVariables("HTTP_USER_AGENT")) moz = instr(ua,"mozilla") ffx = instr(ua,"firefox") saf = instr(ua,"safari") crm = instr(ua,"chrome") max = instr(ua,"maxthon") opr = instr(ua,"opera") ie4 = instr(ua,"msie 4") ie5 = instr(ua,"msie 5") ie6 = instr(ua,"msie 6") ie7 = instr(ua,"msie 7") ie8 = instr(ua,"trident/4.0") ie9 = instr(ua,"trident/5.0") if moz>0 then BrowserType = "Mozilla" BrVer = mid(ua,moz+8,(instr(moz,ua," ")-(moz+8))) end if if ffx>0 then BrowserType = "FireFox" BrVer = mid(ua,ffx+8) end if if saf>0 then BrowserType = "Safari" BrVerPlass = instr(ua,"version") BrVer = mid(ua,BrVerPlass+8,(instr(BrVerPlass,ua," ")-(BrVerPlass+8))) end if if crm>0 then BrowserType = "Chrome" BrVer = mid(ua,crm+7,(instr(crm,ua," ")-(crm+7))) end if if max>0 then BrowserType = "Maxthon" BrVer = mid(ua,max+8,(instr(max,ua," ")-(max+8))) end if if opr>0 then BrowserType = "Opera" BrVerPlass = instr(ua,"presto") BrVer = mid(ua,BrVerPlass+7,(instr(BrVerPlass,ua," ")-(BrVerPlass+7))) end if if ie4>0 then BrowserType = "Internet Explorer" BrVer = "4" end if if ie5>0 then BrowserType = "Internet Explorer" BrVer = "5" end if if ie6>0 then BrowserType = "Internet Explorer" BrVer = "6" end if if ie7>0 then BrowserType = "Internet Explorer" BrVer = "7" end if if ie8>0 then BrowserType = "Internet Explorer" BrVer = "8" if ie7>0 then BrVer = BrVer & " (in IE7 compability mode)" end if if ie9>0 then BrowserType = "Internet Explorer" BrVer = "9" if ie7>0 then BrVer = BrVer & " (in IE7 compability mode)" if ie8>0 then BrVer = BrVer & " (in IE8 compability mode)" end if OSSel = mid(ua,instr(ua,"(")+1,(instr(ua,";")-instr(ua,"("))-1) OSver = mid(ua,instr(ua,";")+1,(instr(ua,")")-instr(ua,";"))-1) if BrowserType = "Internet Explorer" then OSStart = instr(ua,";") OSStart = instr(OSStart+1,ua,";") OSStopp = instr(OSStart+1,ua,";") OSsel = mid(ua,OSStart+2,(OSStopp-OSStart)-2) end if Select case OSsel case "windows nt 6.1" OS = "Windows" OSver = "7" case "windows nt 6.0" OS = "Windows" OSver = "Vista" case "windows nt 5.2" OS = "Windows" OSver = "Srv 2003 / XP x64" case "windows nt 5.1" OS = "Windows" OSver = "XP" case else OS = OSSel End select Response.write "<br>" & ua & "<br>" & BrowserType & "<br>" & BrVer & "<br>" & OS & "<br>" & OSver & "<br>" 'Use the variables here for whatever you need........
var nVer = navigator.appVersion; var nAgt = navigator.userAgent; var browserName = navigator.appName; var fullVersion = ''+parseFloat(navigator.appVersion); var majorVersion = parseInt(navigator.appVersion,10); var nameOffset,verOffset,ix; // In Opera, the true version is after "Opera" or after "Version" if ((verOffset=nAgt.indexOf("Opera"))!=-1) { browserName = "Opera"; fullVersion = nAgt.substring(verOffset+6); if ((verOffset=nAgt.indexOf("Version"))!=-1) fullVersion = nAgt.substring(verOffset+8); } // In MSIE, the true version is after "MSIE" in userAgent else if ((verOffset=nAgt.indexOf("MSIE"))!=-1) { browserName = "Microsoft Internet Explorer"; fullVersion = nAgt.substring(verOffset+5); } // In Chrome, the true version is after "Chrome" else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) { browserName = "Chrome"; fullVersion = nAgt.substring(verOffset+7); } // In Safari, the true version is after "Safari" or after "Version" else if ((verOffset=nAgt.indexOf("Safari"))!=-1) { browserName = "Safari"; fullVersion = nAgt.substring(verOffset+7); if ((verOffset=nAgt.indexOf("Version"))!=-1) fullVersion = nAgt.substring(verOffset+8); } // In Firefox, the true version is after "Firefox" else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) { browserName = "Firefox"; fullVersion = nAgt.substring(verOffset+8); } // In most other browsers, "name/version" is at the end of userAgent else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) ) { browserName = nAgt.substring(nameOffset,verOffset); fullVersion = nAgt.substring(verOffset+1); if (browserName.toLowerCase()==browserName.toUpperCase()) { browserName = navigator.appName; } } // trim the fullVersion string at semicolon/space if present if ((ix=fullVersion.indexOf(";"))!=-1) fullVersion=fullVersion.substring(0,ix); if ((ix=fullVersion.indexOf(" "))!=-1) fullVersion=fullVersion.substring(0,ix); majorVersion = parseInt(''+fullVersion,10); if (isNaN(majorVersion)) { fullVersion = ''+parseFloat(navigator.appVersion); majorVersion = parseInt(navigator.appVersion,10); } document.write('' +'Browser name = '+browserName+'<br>' +'Full version = '+fullVersion+'<br>' +'Major version = '+majorVersion+'<br>' +'navigator.appName = '+navigator.appName+'<br>' +'navigator.userAgent = '+navigator.userAgent+'<br>' )
看到演示在这里.. http://jsfiddle.net/hw4jM/3/
我写了一个基于Hermann Ingjaldsson的答案的版本检测器,但更强大,并返回一个名称/版本数据的对象。 它涵盖了主要的浏览器,但我不打扰大量的移动和次要的:
function getBrowserData(nav) { var data = {}; var ua = data.uaString = nav.userAgent; var browserMatch = ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*([\d\.]+)/i) || []; if (browserMatch[1]) { browserMatch[1] = browserMatch[1].toLowerCase(); } var operaMatch = browserMatch[1] === 'chrome'; if (operaMatch) { operaMatch = ua.match(/\bOPR\/([\d\.]+)/); } if (/trident/i.test(browserMatch[1])) { var msieMatch = /\brv[ :]+([\d\.]+)/g.exec(ua) || []; data.name = 'msie'; data.version = msieMatch[1]; } else if (operaMatch) { data.name = 'opera'; data.version = operaMatch[1]; } else if (browserMatch[1] === 'safari') { var safariVersionMatch = ua.match(/version\/([\d\.]+)/i); data.name = 'safari'; data.version = safariVersionMatch[1]; } else { data.name = browserMatch[1]; data.version = browserMatch[2]; } var versionParts = []; if (data.version) { var versionPartsMatch = data.version.match(/(\d+)/g) || []; for (var i=0; i < versionPartsMatch.length; i++) { versionParts.push(versionPartsMatch[i]); } if (versionParts.length > 0) { data.majorVersion = versionParts[0]; } } data.name = data.name || '(unknown browser name)'; data.version = { full: data.version || '(unknown full browser version)', parts: versionParts, major: versionParts.length > 0 ? versionParts[0] : '(unknown major browser version)' }; return data; };
它可以像这样使用:
var brData = getBrowserData(window.navigator || navigator); console.log('name: ' + brData.name); console.log('major version: ' + brData.version.major); // etc.
<script type="text/javascript"> var version = navigator.appVersion; alert(version); </script>
这个页面似乎有一个相当不错的片段,它只使用appString和appVersion属性作为最后的手段,因为它声称他们是不可靠的某些浏览器。 该页面上的代码如下所示:
var nVer = navigator.appVersion; var nAgt = navigator.userAgent; var browserName = navigator.appName; var fullVersion = ''+parseFloat(navigator.appVersion); var majorVersion = parseInt(navigator.appVersion,10); var nameOffset,verOffset,ix; // In Opera 15+, the true version is after "OPR/" if ((verOffset=nAgt.indexOf("OPR/"))!=-1) { browserName = "Opera"; fullVersion = nAgt.substring(verOffset+4); } // In older Opera, the true version is after "Opera" or after "Version" else if ((verOffset=nAgt.indexOf("Opera"))!=-1) { browserName = "Opera"; fullVersion = nAgt.substring(verOffset+6); if ((verOffset=nAgt.indexOf("Version"))!=-1) fullVersion = nAgt.substring(verOffset+8); } // In MSIE, the true version is after "MSIE" in userAgent else if ((verOffset=nAgt.indexOf("MSIE"))!=-1) { browserName = "Microsoft Internet Explorer"; fullVersion = nAgt.substring(verOffset+5); } // In Chrome, the true version is after "Chrome" else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) { browserName = "Chrome"; fullVersion = nAgt.substring(verOffset+7); } // In Safari, the true version is after "Safari" or after "Version" else if ((verOffset=nAgt.indexOf("Safari"))!=-1) { browserName = "Safari"; fullVersion = nAgt.substring(verOffset+7); if ((verOffset=nAgt.indexOf("Version"))!=-1) fullVersion = nAgt.substring(verOffset+8); } // In Firefox, the true version is after "Firefox" else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) { browserName = "Firefox"; fullVersion = nAgt.substring(verOffset+8); } // In most other browsers, "name/version" is at the end of userAgent else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) ) { browserName = nAgt.substring(nameOffset,verOffset); fullVersion = nAgt.substring(verOffset+1); if (browserName.toLowerCase()==browserName.toUpperCase()) { browserName = navigator.appName; } } // trim the fullVersion string at semicolon/space if present if ((ix=fullVersion.indexOf(";"))!=-1) fullVersion=fullVersion.substring(0,ix); if ((ix=fullVersion.indexOf(" "))!=-1) fullVersion=fullVersion.substring(0,ix); majorVersion = parseInt(''+fullVersion,10); if (isNaN(majorVersion)) { fullVersion = ''+parseFloat(navigator.appVersion); majorVersion = parseInt(navigator.appVersion,10); } document.write('' +'Browser name = '+browserName+'<br>' +'Full version = '+fullVersion+'<br>' +'Major version = '+majorVersion+'<br>' +'navigator.appName = '+navigator.appName+'<br>' +'navigator.userAgent = '+navigator.userAgent+'<br>' )
这里是某个人的Java版本,他们希望在服务器端使用由HttpServletRequest.getHeader("User-Agent");
返回的string进行HttpServletRequest.getHeader("User-Agent");
它正在使用我用于testing的70种不同的浏览器configuration。
public static String decodeBrowser(String userAgent) { userAgent= userAgent.toLowerCase(); String name = "unknown"; String version = "0.0"; Matcher userAgentMatcher = USER_AGENT_MATCHING_PATTERN.matcher(userAgent); if (userAgentMatcher.find()) { name = userAgentMatcher.group(1); version = userAgentMatcher.group(2); if ("trident".equals(name)) { name = "msie"; Matcher tridentVersionMatcher = TRIDENT_MATCHING_PATTERN.matcher(userAgent); if (tridentVersionMatcher.find()) { version = tridentVersionMatcher.group(1); } } } return name + " " + version; } private static final Pattern USER_AGENT_MATCHING_PATTERN=Pattern.compile("(opera|chrome|safari|firefox|msie|trident(?=\\/))\\/?\\s*([\\d\\.]+)"); private static final Pattern TRIDENT_MATCHING_PATTERN=Pattern.compile("\\brv[ :]+(\\d+(\\.\\d+)?)");
我为我的需求写了这个。
它获得的信息就好像是移动设备还是具有视网膜显示
尝试一下
var nav = { isMobile:function(){ return (navigator.userAgent.match(/iPhone|iPad|iPod|Android|BlackBerry|Opera Mini|IEMobile/i) != null); }, isDesktop:function(){ return (navigator.userAgent.match(/iPhone|iPad|iPod|Android|BlackBerry|Opera Mini|IEMobile/i) == null); }, isAndroid: function() { return navigator.userAgent.match(/Android/i); }, isBlackBerry: function() { return navigator.userAgent.match(/BlackBerry/i); }, isIOS: function() { return navigator.userAgent.match(/iPhone|iPad|iPod/i); }, isOpera: function() { return navigator.userAgent.match(/Opera Mini/i); }, isWindows: function() { return navigator.userAgent.match(/IEMobile/i); }, isRetina:function(){ return window.devicePixelRatio && window.devicePixelRatio > 1; }, isIPad:function(){ isIPad = (/ipad/gi).test(navigator.platform); return isIPad; }, isLandscape:function(){ if(window.innerHeight < window.innerWidth){ return true; } return false; }, getIOSVersion:function(){ if(this.isIOS()){ var OSVersion = navigator.appVersion.match(/OS (\d+_\d+)/i); OSVersion = OSVersion[1] ? +OSVersion[1].replace('_', '.') : 0; return OSVersion; } else return false; }, isStandAlone:function(){ if(_.is(navigator.standalone)) return navigator.standalone; return false; }, isChrome:function(){ var isChrome = (/Chrome/gi).test(navigator.appVersion); var isSafari = (/Safari/gi).test(navigator.appVersion) return isChrome && isSafari; }, isSafari:function(){ var isSafari = (/Safari/gi).test(navigator.appVersion) var isChrome = (/Chrome/gi).test(navigator.appVersion) return !isChrome && isSafari; } }
添加我自己的赫尔曼答案的实现。 我需要操作系统检测,因此被添加。 还包括一些ES6代码(因为我们有一个译码器),你可能需要ES5-ify。
detectClient() { let nav = navigator.appVersion, os = 'unknown', client = (() => { let agent = navigator.userAgent, engine = agent.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [], build; if(/trident/i.test(engine[1])){ build = /\brv[ :]+(\d+)/g.exec(agent) || []; return {browser:'IE', version:(build[1] || '')}; } if(engine[1] === 'Chrome'){ build = agent.match(/\bOPR\/(\d+)/); if(build !== null) { return {browser: 'Opera', version: build[1]}; } } engine = engine[2] ? [engine[1], engine[2]] : [navigator.appName, nav, '-?']; if((build = agent.match(/version\/(\d+)/i)) !== null) { engine.splice(1, 1, build[1]); } return { browser: engine[0], version: engine[1] }; })(); switch (true) { case nav.indexOf('Win') > -1: os = 'Windows'; break; case nav.indexOf('Mac') > -1: os = 'MacOS'; break; case nav.indexOf('X11') > -1: os = 'UNIX'; break; case nav.indexOf('Linux') > -1: os = 'Linux'; break; } client.os = os; return client; }
返回: Object {browser: "Chrome", version: "50", os: "UNIX"}
var nVer = navigator.appVersion; var nAgt = navigator.userAgent; var browserName = navigator.appName; var fullVersion = '' + parseFloat(navigator.appVersion); var majorVersion = parseInt(navigator.appVersion, 10); var nameOffset, verOffset, ix; // In Opera 15+, the true version is after "OPR/" if ((verOffset = nAgt.indexOf("OPR/")) != -1) { browserName = "Opera"; fullVersion = nAgt.substring(verOffset + 4); } // In older Opera, the true version is after "Opera" or after "Version" else if ((verOffset = nAgt.indexOf("Opera")) != -1) { browserName = "Opera"; fullVersion = nAgt.substring(verOffset + 6); if ((verOffset = nAgt.indexOf("Version")) != -1) fullVersion = nAgt.substring(verOffset + 8); } // In MSIE, the true version is after "MSIE" in userAgent else if ((verOffset = nAgt.indexOf("MSIE")) != -1) { browserName = "Microsoft Internet Explorer"; fullVersion = nAgt.substring(verOffset + 5); } // In Chrome, the true version is after "Chrome" else if ((verOffset = nAgt.indexOf("Chrome")) != -1) { browserName = "Google Chrome"; fullVersion = nAgt.substring(verOffset + 7); } // In Safari, the true version is after "Safari" or after "Version" else if ((verOffset = nAgt.indexOf("Safari")) != -1) { browserName = "Safari"; fullVersion = nAgt.substring(verOffset + 7); if ((verOffset = nAgt.indexOf("Version")) != -1) fullVersion = nAgt.substring(verOffset + 8); } // In Firefox, the true version is after "Firefox" else if ((verOffset = nAgt.indexOf("Firefox")) != -1) { browserName = "Mozilla Firefox"; fullVersion = nAgt.substring(verOffset + 8); } // In most other browsers, "name/version" is at the end of userAgent else if ((nameOffset = nAgt.lastIndexOf(' ') + 1) < (verOffset = nAgt.lastIndexOf('/'))) { browserName = nAgt.substring(nameOffset, verOffset); fullVersion = nAgt.substring(verOffset + 1); if (browserName.toLowerCase() == browserName.toUpperCase()) { browserName = navigator.appName; } } // trim the fullVersion string at semicolon/space if present if ((ix = fullVersion.indexOf(';')) != -1) fullVersion = fullVersion.substring(0, ix); if ((ix = fullVersion.indexOf(' ')) != -1) fullVersion = fullVersion.substring(0, ix); majorVersion = parseInt('' + fullVersion, 10); if (isNaN(majorVersion)) { fullVersion = '' + parseFloat(navigator.appVersion); majorVersion = parseInt(navigator.appVersion, 10); }
var ua = navigator.userAgent; if (/Firefox\//.test(ua)) var Firefox = /Firefox\/([0-9\.Az]+)/.exec(ua)[1];