Browser Detect - Description

The Browser Detect script was originally a scaled-down version of the Ultimate Client Sniffer. With the passing of time and a complete re-write, it now bears little resemblance to the original. I have concentrated on recent browsers which make up 99.9% of the general internet population. It also detects the Javascript version and platform. This information is stored in variables in a browser object which allows the creation of very readible code. For instance, on Netscape 4.7, the property browser.isNS4 would be true while browser.isIE would be false. A complete list of properties and their meanings can be found in the usage instructions.

The latest version features improved version detection, differentiates between Netscape 6.x and Mozilla, and the ability to detect Gecko as an embedded layout engine. Version 2.0 is not backward compatible with version 1.x of this script.

This browser detection script relies on the browser identifying itself correctly through it's User-Agent HTTP header. Some browsers allow the user to modify this value to the point where this script will not be able to correctly identify their browser and may mis-identify it as a different browser. An alternative to relying on the User-Agent value is to identify a visiting browser by looking for specific quirks in the browser's implementation of Javascript. Though I haven't written a script that does this, others have. Because even this method is not foolproof (a new browser may have the same quirks as a known browser of a different make) and because few (probably less than 0.01%) users change their browsers User-Agent value, I prefer my method.

Script Engine / Document Object Model Required

Javascript 1.0 | JScript 1.0 | ECMAScript 1.0

Modification History

2000/09/11

Posted.

2000/11/14

Fixed a bug that mis-reported the Javascript version supported by Netscape 6.

2001/06/11 v1.0

Fixed a bug that mis-reported IE5.5 as IE4 and added IE6 support.

2001/08/31 v1.01

Fixed IE6 support (it was ok for the beta version but not the released non-beta).

2002/03/28 v2.0

New version with a different approach. Not backward compatible.

2002/04/01 v2.1

Fixed Mozilla after-load support.

2002/07/02 v2.1.1

Added properties that reflect DOM support and quirks/standards modes.

2002/07/02 v2.1.1

Added NS7 detection and improved version number reporting for Mozilla.

2002/12/02 v2.1.3

Fixed WinXP detection under Opera (Opera doesn't use the standard "Windows NT 5.1" but "Windows XP") (thanks Zakoops).

2003/03/11 v2.1.4

Added Safari and removed WebTV detection. Safari is currently in beta so the versionMajor and versionMinor report the build number (this may change). Also made a separate detection for Linux (separate from Unix).

2003/09/09 v2.1.5

Prevented Safari from returning true on isNS.

2003/12/20

Changed the name of the script to browser_detect.js (dropping the "lite" bit) and updated the documentation to match.

2003/12/26 v2.1.6

Added OmniWeb support, AppleWebKit and equivalent-Mozilla version numbers.

2004/04/15 v2.1.7

Changed isFirebird variable to isFirefox (thanks nasten).

More about this script

Licensing

This script is released under a Creative Commons License.