Here are the results of running that JavaScript code on the browser you are using. The below text has been dynamically generated after checking your browser vendor, version, and operating system from JavaScript.
Basic Data
Version Number
Browser Version
JavaScript Version
OS
You're probably wondering
why we created a bunch of variables with similar names instead of doing
something more elegant like this:
function Is ()
{ var agt=navigator.userAgent.toLowerCase();
this.major = parseInt(navigator.appVersion);
this.minor = parseFloat(navigator.appVersion);
this.nav = ((agt.indexOf('mozilla')!=-1) && ((agt.indexOf('spoofer')==-1)
&& (agt.indexOf('compatible') == -1)));
this.nav2 = (this.nav && (this.major == 2));
this.nav3 = (this.nav && (this.major == 3));
... and so on ...
this.vms = (agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1);
}
var is = new Is();
if (is.nav) { ... navigator code here ... }
else if (is.ie) { ... explorer code here ... }
The answer is simple: this
code is far more elegant, providing encapsulation of the variables with
an enclosing "is" object, but it breaks on Internet Explorer 3 for the
Macintosh. If you create an "is" object on IE3 for the Mac, the first time
the page is loaded, the code will work fine, however any reloads of the
page will cause the browser to crash. To get around this on IE3 for the
Mac, we don't create an "is" object; instead, we create bunch of boolean
variables which have similar names. This is ugly, but it's the price we
pay for working around this bug of JScript for the Macintosh in IE3.
Another possible workaround
is to use the object oriented code on all other browsers but wrap it in
a check which avoids executing the object oriented code on IE3 for the
Mac. This preserves the object oriented design of the code but requires
an extra boolean check like if (!isIE3Mac &&
is_nav4up) each time you
reference the is
object. As this extra boolean check is inconvenient, we've resigned ourselves
to the simple non-object oriented version above. However, if you prefer
the object oriented approach, we provide a object
oriented client sniffer with a safety check for the Mac. Finally, if
you don't need to support IE3 for the Mac, you can use that object
oriented code and omit the Mac safety check.
For the latest technical information on Sun-Netscape Alliance products, go to: http://developer.iplanet.com
For more Internet development resources, try Netscape TechSearch.
Copyright © 1999-2001 Netscape Communications Corporation.