> > In this sniffing code, the navigator object is interrogated for its version.
> > If the version is "6", then the browser is understood to be Netscape 6.
> > Otherwise, if the "MSIE" string is not found as part of the property, then the
> > browser is IE5.
> >
> > if (navigator.appVersion.charAt(0) == "5") {
> > if (navigator.appName == "Netscape") {
> > isNav6 = true
> > alert('NS6')
> > }
> > }
> > else if (navigator.appVersion.indexOf("MSIE") != -1) {
> > isIE = true
> > alert('IE')
> > }
>
> I'm not familiar with JavaScript, but it seems to me that the last sentence
> has an extra negation. Wouldn't it be "if the string 'MSIE' _is_ found"?
indexOf("MSIE") will return a positive number if the stiring is found.
If it isn't it will return a -1. By checking to see if the result is
not -1 you are essentially checking to see if the result >= 0.
I see one other problem with this snippit of code. What happens when
Microsoft releases a version of their browser with an appVersion of 5?
It will enter the fist part of the if statement. It's appName is not
Netscape and it will drop out.