3 * $Revision: 1.2 $ $Date: 2003/02/07 16:04:17 $
\r
6 /* ***** BEGIN LICENSE BLOCK *****
\r
7 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
\r
9 * The contents of this file are subject to the Mozilla Public License Version
\r
10 * 1.1 (the "License"); you may not use this file except in compliance with
\r
11 * the License. You may obtain a copy of the License at
\r
12 * http://www.mozilla.org/MPL/
\r
14 * Software distributed under the License is distributed on an "AS IS" basis,
\r
15 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
\r
16 * for the specific language governing rights and limitations under the
\r
19 * The Original Code is Netscape code.
\r
21 * The Initial Developer of the Original Code is
\r
22 * Netscape Corporation.
\r
23 * Portions created by the Initial Developer are Copyright (C) 2001
\r
24 * the Initial Developer. All Rights Reserved.
\r
26 * Contributor(s): Bob Clary <bclary@netscape.com>
\r
28 * ***** END LICENSE BLOCK ***** */
\r
30 function xbDetectBrowser()
\r
32 var oldOnError = window.onerror;
\r
35 window.onerror = null;
\r
37 // work around bug in xpcdom Mozilla 0.9.1
\r
38 window.saveNavigator = window.navigator;
\r
41 navigator.version = parseFloat(navigator.appVersion);
\r
43 navigator.family = '';
\r
46 if (typeof(window.navigator.platform) != 'undefined')
\r
48 platform = window.navigator.platform.toLowerCase();
\r
49 if (platform.indexOf('win') != -1)
\r
50 navigator.OS = 'win';
\r
51 else if (platform.indexOf('mac') != -1)
\r
52 navigator.OS = 'mac';
\r
53 else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1)
\r
54 navigator.OS = 'nix';
\r
58 var ua = window.navigator.userAgent.toLowerCase();
\r
60 if (ua.indexOf('opera') != -1)
\r
62 i = ua.indexOf('opera');
\r
63 navigator.family = 'opera';
\r
64 navigator.org = 'opera';
\r
65 navigator.version = parseFloat('0' + ua.substr(i+6), 10);
\r
67 else if ((i = ua.indexOf('msie')) != -1)
\r
69 navigator.org = 'microsoft';
\r
70 navigator.version = parseFloat('0' + ua.substr(i+5), 10);
\r
72 if (navigator.version < 4)
\r
73 navigator.family = 'ie3';
\r
75 navigator.family = 'ie4'
\r
77 else if (ua.indexOf('gecko') != -1)
\r
79 navigator.family = 'gecko';
\r
80 var rvStart = ua.indexOf('rv:');
\r
81 var rvEnd = ua.indexOf(')', rvStart);
\r
82 var rv = ua.substring(rvStart+3, rvEnd);
\r
83 var rvParts = rv.split('.');
\r
87 for (var i = 0; i < rvParts.length; i++)
\r
89 var val = parseInt(rvParts[i]);
\r
90 rvValue += val / exp;
\r
93 navigator.version = rvValue;
\r
95 if (ua.indexOf('netscape') != -1)
\r
96 navigator.org = 'netscape';
\r
97 else if (ua.indexOf('compuserve') != -1)
\r
98 navigator.org = 'compuserve';
\r
100 navigator.org = 'mozilla';
\r
102 else if ((ua.indexOf('mozilla') !=-1) && (ua.indexOf('spoofer')==-1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera')==-1)&& (ua.indexOf('webtv')==-1) && (ua.indexOf('hotjava')==-1))
\r
104 var is_major = parseFloat(navigator.appVersion);
\r
107 navigator.version = is_major;
\r
110 i = ua.lastIndexOf('/')
\r
111 navigator.version = parseFloat('0' + ua.substr(i+1), 10);
\r
113 navigator.org = 'netscape';
\r
114 navigator.family = 'nn' + parseInt(navigator.appVersion);
\r
116 else if ((i = ua.indexOf('aol')) != -1 )
\r
119 navigator.family = 'aol';
\r
120 navigator.org = 'aol';
\r
121 navigator.version = parseFloat('0' + ua.substr(i+4), 10);
\r
123 else if ((i = ua.indexOf('hotjava')) != -1 )
\r
126 navigator.family = 'hotjava';
\r
127 navigator.org = 'sun';
\r
128 navigator.version = parseFloat(navigator.appVersion);
\r
131 window.onerror = oldOnError;
\r