|
|
|||||
|
Ready to Use Script Archive | | | Over 5000 Free Fonts | | | Tutorials | | | Javascript Forum | | | Other Javascript Resources | | | Cheat Sheet |
Browser VersionQuestion: How do I detect the browser version?
Answer:
In most cases, you can use the value
In some cases, however, you might need the full version number
in the Thus, to get the full version number of any of the above browsers, you can use the following code: var nVer = navigator.appVersion; var nAgt = navigator.userAgent; var fullVersion = parseFloat(nVer); var majorVersion = parseInt(nVer); // In Internet Explorer, the true version is after "MSIE" if ((verOffset=nAgt.indexOf("MSIE"))!=-1) { fullVersion = parseFloat(nAgt.substring(verOffset+5,nAgt.length)); majorVersion = parseInt(''+fullVersion); } // In Opera, the true version is after "Opera" if ((verOffset=nAgt.indexOf("Opera"))!=-1) { fullVersion = parseFloat(nAgt.substring(verOffset+6,nAgt.length)); majorVersion = parseInt(''+fullVersion); } document.write('Full version = '+fullVersion+'<br>'); document.write('Major version = '+majorVersion);In your browser, this code produces the following output:
|
|