In order to deal with the many different browsers in use on the Web you need a way for your scripts to tell them apart. Luckily all browsers "announce" themselves with the User-Agent property (see accompanying article), although it can be a pain to keep all the variations apart. The BrowserDetector function isolates the potentially useful portions of the User-Agent string so you can go about the business of making Web pages that work for all browsers.
Usage:var bd = new BrowserDetector(navigator.userAgent);
This will create a new BrowserDetector object named "bd" with the following properties (see the demo page for examples using actual User-Agent strings):
bd.browser
bd.platform
bd.version
bd.majorver
bd.minorver
Example: The following would redirect users to two different pages depending on whether they were using a version of Netscape or Internet Explorer.
var bd = new BrowserDetector(navigator.userAgent);
if (bd.browser == "Netscape") {
location = "ns_version.html";
}
else if (bd.browser == "IE") {
location = "ie_version.html";
}