|
// To obtain the major version number var sVersion = parseInt(navigator.appVersion) + ""; |
||
|
|
||
|
// Or to obtain the full version number var sVersion = parseFloat(navigator.appVersion) + ""; |
||
|
|
||
If only it were that simple! Unfortunately, Internet Explorer is not always correctly identified using this technique. On the one hand, IE3 returns a version number of 2 and on the other, IE5 returns a version number of 4. What a mess! I generally accept the version numbers as given, since IE3 actually only has the functionality of NS2 and IE5, for most purposes, has the functionality of IE4. However, if for some reason you must know the version numbers more accurately, you can add the following code: |
|
// To obtain the major version number var sVersion = parseFloat(navigator.appVersion) + ""; if (sBrowser == "IE") { var iInfo = navigator.appVersion.indexOf("MSIE ") + 5; var sInfo = navigator.appVersion.substring(iInfo); sVersion = parseInt(sInfo) + ""; } |
||
|
|
||
|
// Or to obtain the full version number var sVersion = parseFloat(navigator.appVersion) + ""; if (sBrowser == "IE") { var iInfo = navigator.appVersion.indexOf("MSIE ") + 5; var sInfo = navigator.appVersion.substring(iInfo); sVersion = parseFloat(sInfo) + ""; } |
||
|
|
||
NOTE: The only difference between obtaining the major version number and the full version number is the use of parseInt and parseFloat, respectively. As you can see, this gets quite complicated. For that reason, I generally stay with the major version numbers obtained by the first method. Since the functionality of IE3 is essentially that of NS2 and the functionality of IE5 is essentially that of IE4, there is, in my opinion, no reason to go into a more precise determination of the browser version number except for special circumstances. Now let's take a look at how to find the platform. Continue |
| © 1999
bnsDesigns |