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