2 * $Log: not supported by cvs2svn $
3 * Revision 1.9 2002/07/22 14:06:21 bc6ix
4 * fix license path, change version reporting to use 2 digits for each level
6 * Revision 1.8 2002/07/07 08:23:07 bc6ix
9 * Revision 1.7 2002/05/14 16:52:52 bc6ix
10 * use CVS Log for revision history
15 /* ***** BEGIN LICENSE BLOCK *****
16 * Licensed under Version: MPL 1.1/GPL 2.0/LGPL 2.1
17 * Full Terms at http://bclary.com/lib/js/license/mpl-tri-license.txt
19 * Software distributed under the License is distributed on an "AS IS" basis,
20 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
21 * for the specific language governing rights and limitations under the
24 * The Original Code is Netscape code.
26 * The Initial Developer of the Original Code is
27 * Netscape Corporation.
28 * Portions created by the Initial Developer are Copyright (C) 2001
29 * the Initial Developer. All Rights Reserved.
31 * Contributor(s): Bob Clary <bclary@netscape.com>
33 * ***** END LICENSE BLOCK ***** */
35 function xbDetectBrowser()
37 var oldOnError = window.onerror;
40 window.onerror = null;
42 // work around bug in xpcdom Mozilla 0.9.1
43 window.saveNavigator = window.navigator;
46 navigator.version = parseFloat(navigator.appVersion);
48 navigator.family = '';
51 if (typeof(window.navigator.platform) != 'undefined')
53 platform = window.navigator.platform.toLowerCase();
54 if (platform.indexOf('win') != -1)
56 else if (platform.indexOf('mac') != -1)
58 else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1)
63 var ua = window.navigator.userAgent.toLowerCase();
65 if (ua.indexOf('safari') != -1)
67 i = ua.indexOf('safari');
68 navigator.family = 'safari';
69 navigator.org = 'safari';
70 navigator.version = parseFloat('0' + ua.substr(i+7), 10);
72 else if (ua.indexOf('opera') != -1)
74 i = ua.indexOf('opera');
75 navigator.family = 'opera';
76 navigator.org = 'opera';
77 navigator.version = parseFloat('0' + ua.substr(i+6), 10);
79 else if ((i = ua.indexOf('msie')) != -1)
81 navigator.org = 'microsoft';
82 navigator.version = parseFloat('0' + ua.substr(i+5), 10);
84 if (navigator.version < 4)
85 navigator.family = 'ie3';
87 navigator.family = 'ie4'
89 else if (ua.indexOf('gecko') != -1)
91 navigator.family = 'gecko';
92 var rvStart = ua.indexOf('rv:');
93 var rvEnd = ua.indexOf(')', rvStart);
94 var rv = ua.substring(rvStart+3, rvEnd);
95 var rvParts = rv.split('.');
99 for (var i = 0; i < rvParts.length; i++)
101 var val = parseInt(rvParts[i]);
102 rvValue += val / exp;
105 navigator.version = rvValue;
107 if (ua.indexOf('netscape') != -1)
108 navigator.org = 'netscape';
109 else if (ua.indexOf('compuserve') != -1)
110 navigator.org = 'compuserve';
112 navigator.org = 'mozilla';
114 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))
116 var is_major = parseFloat(navigator.appVersion);
119 navigator.version = is_major;
122 i = ua.lastIndexOf('/')
123 navigator.version = parseFloat('0' + ua.substr(i+1), 10);
125 navigator.org = 'netscape';
126 navigator.family = 'nn' + parseInt(navigator.appVersion);
128 else if ((i = ua.indexOf('aol')) != -1 )
131 navigator.family = 'aol';
132 navigator.org = 'aol';
133 navigator.version = parseFloat('0' + ua.substr(i+4), 10);
135 else if ((i = ua.indexOf('hotjava')) != -1 )
138 navigator.family = 'hotjava';
139 navigator.org = 'sun';
140 navigator.version = parseFloat(navigator.appVersion);
143 window.onerror = oldOnError;