home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / ua.js < prev    next >
Encoding:
JavaScript  |  2004-03-24  |  3.2 KB  |  112 lines

  1. /*
  2. ua.js revision 0.200 2001-12-03
  3.  
  4. Contributor(s): Bob Clary, Netscape Communications, Copyright 2001
  5.  
  6. Netscape grants you a royalty free license to use, modify and 
  7. distribute this software provided that this copyright notice 
  8. appears on all copies.  This software is provided "AS IS," 
  9. without a warranty of any kind.
  10. */
  11.  
  12. function xbDetectBrowser()
  13. {
  14.   var oldOnError = window.onerror;
  15.   var element = null;
  16.  
  17.   window.onerror = null;
  18.   
  19.   // work around bug in xpcdom Mozilla 0.9.1
  20.   window.saveNavigator = window.navigator;
  21.  
  22.   navigator.OS    = '';
  23.   navigator.version  = parseFloat(navigator.appVersion);
  24.   navigator.org    = '';
  25.   navigator.family  = '';
  26.  
  27.   var platform;
  28.   if (typeof(window.navigator.platform) != 'undefined')
  29.   {
  30.     platform = window.navigator.platform.toLowerCase();
  31.     if (platform.indexOf('win') != -1)
  32.       navigator.OS = 'win';
  33.     else if (platform.indexOf('mac') != -1)
  34.       navigator.OS = 'mac';
  35.     else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1)
  36.       navigator.OS = 'nix';
  37.   }
  38.  
  39.   var i = 0;
  40.   var ua = window.navigator.userAgent.toLowerCase();
  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.  
  111. xbDetectBrowser();
  112.