Okay, so you've begun to use all kinds of *kewl* JavaScript on your web pages, but you're starting to discover conflicts. Some scripts won't work in Netscape 2, because they employ new tags developed for the second release of JavaScript (which emerged with Netscape version 3.03a perfect example is those graphic image roll-overs you see on so many people's navigation bars (they bring up errors in earlier versions of Netscape, which used the first release of JavaScript, before the Image object became part of the language
)). Others, which employ Dynamic HTML only work in Netscape 4 or greater.
Thus, it's important to check for the browser version and prevent errors from popping-up all over the place if someone runs your script in a browser that doesn't support the version of JavaScript in which you've coded. You only want your new scripts to work in the browsers that support them, right?
Here's a clue as to how to determine the browser versions.
parseFloat(navigator.appVersion) gives the version number in all navigator browsers.
Version 2 seems to be the only one that will automatically recognize navigator.appVersion as a number.
All later browsers need to use parseFloat(navigator.appVersion) or parseInt(navigator.appVersion) to determine the version number.
Thus, if you're trying to see if the browser runs the first JavaScript release (in browsers up to version 3.03), use:
if (parseFloat(navigator.appVersion) < 3.03)
To check for browsers that use the second JavaScript release, use:
if (parseFloat(navigator.appVersion) >= 3.03)
Finally, to check for 4.0 browsers (and DHTML ability), use:
if (parseInt(navigator.appVersion) >= 4)