1/* 2ua.js 2001-12-05 3 4Contributor(s): Bob Clary, Netscape Communications, Copyright 2001 5 6Netscape grants you a royalty free license to use or modify this 7software provided that this copyright notice appears on all copies. 8This software is provided "AS IS," without a warranty of any kind. 9*/ 10 11function xbDetectBrowser() 12{ 13 var oldOnError = window.onerror; 14 var element = null; 15 16 window.onerror = null; 17 18 // work around bug in xpcdom Mozilla 0.9.1 19 window.saveNavigator = window.navigator; 20 21 navigator.OS = ''; 22 navigator.version = parseFloat(navigator.appVersion); 23 navigator.org = ''; 24 navigator.family = ''; 25 26 var platform; 27 if (typeof(window.navigator.platform) != 'undefined') 28 { 29 platform = window.navigator.platform.toLowerCase(); 30 if (platform.indexOf('win') != -1) 31 navigator.OS = 'win'; 32 else if (platform.indexOf('mac') != -1) 33 navigator.OS = 'mac'; 34 else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1) 35 navigator.OS = 'nix'; 36 } 37 38 var i = 0; 39 var ua = window.navigator.userAgent.toLowerCase(); 40 41 if (ua.indexOf('opera') != -1) 42 { 43 i = ua.indexOf('opera'); 44 navigator.family = 'opera'; 45 navigator.org = 'opera'; 46 navigator.version = parseFloat('0' + ua.substr(i+6), 10); 47 } 48 else if ((i = ua.indexOf('msie')) != -1) 49 { 50 navigator.org = 'microsoft'; 51 navigator.version = parseFloat('0' + ua.substr(i+5), 10); 52 53 if (navigator.version < 4) 54 navigator.family = 'ie3'; 55 else 56 navigator.family = 'ie4' 57 } 58 else if (ua.indexOf('gecko') != -1) 59 { 60 navigator.family = 'gecko'; 61 var rvStart = navigator.userAgent.indexOf('rv:') + 3; 62 var rvEnd = navigator.userAgent.indexOf(')', rvStart);
63 var rv = navigator.userAgent.substring(rvStart, rvEnd); 64 var decIndex = rv.indexOf('.'); 65 if (decIndex != -1) 66 { 67 rv = rv.replace(/\./g, '') 68 rv = rv.substring(0, decIndex-1) + '.' + rv.substr(decIndex) 69 } 70 navigator.version = parseFloat(rv); 71 72 if (ua.indexOf('netscape') != -1) 73 navigator.org = 'netscape'; 74 else if (ua.indexOf('compuserve') != -1) 75 navigator.org = 'compuserve'; 76 else 77 navigator.org = 'mozilla'; 78 } 79 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)) 80 { 81 var is_major = parseFloat(navigator.appVersion); 82 83 if (is_major < 4) 84 navigator.version = is_major; 85 else 86 { 87 i = ua.lastIndexOf('/') 88 navigator.version = parseFloat('0' + ua.substr(i+1), 10); 89 } 90 navigator.org = 'netscape'; 91 navigator.family = 'nn' + parseInt(navigator.appVersion); 92 } 93 else if ((i = ua.indexOf('aol')) != -1 ) 94 { 95 // aol 96 navigator.family = 'aol'; 97 navigator.org = 'aol'; 98 navigator.version = parseFloat('0' + ua.substr(i+4), 10); 99 } 100 else if ((i = ua.indexOf('hotjava')) != -1 ) 101 { 102 // hotjava 103 navigator.family = 'hotjava'; 104 navigator.org = 'sun'; 105 navigator.version = parseFloat(navigator.appVersion); 106 } 107 108 window.onerror = oldOnError; 109} 110 111xbDetectBrowser(); 112
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.