January 24, 2000 - Version Detection | WebReference

January 24, 2000 - Version Detection

Yehuda Shiran January 25, 2000
Version Detection
Tips: January 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

When you want to sniff the browser version, be aware that Internet Explorer and Netscape Navigator have different version assignment schemes. The version information can be found in the navigator object's appVersion property. If we print this property from Internet Explorer, it looks like this:

The printout from Netscape Navigator will look like this:

Notice that Internet Explorer shows two versions, 4.0 and 5.0 in the example above. The Compatible Version (4.0) denotes the previous compatible version. The other version (5.0) denotes the actual version of the browser. Netscape Navigator shows just one number, the current version number (4.08). So how do we extract the version? If we are interested in the compatible version (4.0), then we can use the parseFloat() method. It always returns the compatible version on the Internet Explorer and the normal browser version on Netscape Navigator. If you need the browser version in Internet Explorer, you have to resort to the indexOf() method. Use it to locate specific substrings and then convert them to float. Check your browser's version now:

Learn more about the appVersion property in Jan 14, 2000's tip.