home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / ScriptBuilder / NOSB30_TRIAL.exe / data1.cab / Program_Files / CompLib / browser.js < prev    next >
Encoding:
Text File  |  1998-10-05  |  6.1 KB  |  162 lines

  1. function com_netobjects_browserComponent( params ) {
  2.     this.getCurrentBrowserInt = getCurrentBrowserInt;
  3.     this.getCurrentBrowserStr = getCurrentBrowserStr;
  4.     this.getCurrentBrowser = getCurrentBrowser;
  5.  
  6.     //events
  7.     this.onIE3 = (params.onIE3+"" != "undefined" ? params.onIE3 : null);
  8.     this.onIE4 = (params.onIE4+"" != "undefined" ? params.onIE4 : null);
  9.     this.onIE5 = (params.onIE5+"" != "undefined" ? params.onIE5 : null);
  10.     this.onIE = (params.onIE+"" != "undefined" ? params.onIE : null);
  11.  
  12.     this.onNS = (params.onNS+"" != "undefined" ? params.onNS : null);
  13.     this.onNS2 = (params.onNS2+"" != "undefined" ? params.onNS2 : null);
  14.     this.onNS3 = (params.onNS3+"" != "undefined" ? params.onNS3 : null);
  15.     this.onNS4 = (params.onNS4+"" != "undefined" ? params.onNS4 : null);
  16.     this.onNS5 = (params.onNS5+"" != "undefined" ? params.onNS5 : null); 
  17.  
  18.     this.name = params.name;
  19.  
  20.     this.onOther = (params.onOther+"" != "undefined" ? params.onOther : null);
  21.     
  22.     /* ======================================================================
  23.     FUNCTION:    getCurrentBrowserStr 
  24.      
  25.     INPUT:         none.
  26.     
  27.     RETURN:        a string indicating the current browser
  28.     
  29.     DESC:            This function is used with client-side JavaScript to detect
  30.                     the brand and version of the user's browser.  Detects only
  31.                     Netscape and Microsoft browsers.  Returns "Other" if a different
  32.                     brand is detected.
  33.     
  34.     PLATFORMS:    Netscape Navigator 3.01 and higher,
  35.                       Microsoft Internet Explorer 3.02 and higher,
  36.     ====================================================================== */
  37.     function getCurrentBrowserStr() {
  38.         var current_browser = ""; 
  39.         var bwr = new String(navigator.appName);
  40.         var ver = parseInt(navigator.appVersion, 10); 
  41.  
  42.         if(ver+"" != "NaN")
  43.         {
  44.           if ( bwr.toUpperCase() == "NETSCAPE" && ver == 5 ) current_browser = "Netscape 5.0"; 
  45.           else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 4 ) current_browser = "Netscape 4.0"; 
  46.           else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 3 ) current_browser = "Netscape 3.0";  
  47.           else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 2 ) current_browser = "Netscape 2.0"; 
  48.           else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 3 ) current_browser = "MSIE 3.0"; 
  49.           else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 4 ) current_browser = "MSIE 4.0"; 
  50.           else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 5 ) current_browser = "MSIE 5.0"; 
  51.           else current_browser = "Other";
  52.        }    
  53.         return current_browser;
  54.     } // end getCurrentBrowserStr
  55.     
  56.     /* ======================================================================
  57.     FUNCTION:    getCurrentBrowserInt 
  58.      
  59.     INPUT:         none.
  60.     
  61.     RETURN:        a integer indicating the index of the current browser
  62.     
  63.     DESC:            This function is used with client-side JavaScript to detect
  64.                     the brand and version of the user's browser.  Detects only
  65.                     Netscape and Microsoft browsers.  Returns 0 if a different
  66.                     brand is detected.
  67.     
  68.     PLATFORMS:    Netscape Navigator 3.01 and higher,
  69.                       Microsoft Internet Explorer 3.02 and higher,
  70.     ====================================================================== */
  71.  
  72.     function getCurrentBrowserInt() {
  73.         var current_browser = 0; 
  74.         var bwr = new String(navigator.appName);
  75.         var ver = parseInt(navigator.appVersion, 10); 
  76.  
  77.         if(ver+"" != "NaN")
  78.         {
  79.           if ( bwr.toUpperCase() == "NETSCAPE" && ver == 5 ) current_browser = 4; 
  80.           else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 4 ) current_browser = 3; 
  81.           else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 3 ) current_browser = 2;  
  82.           else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 2 ) current_browser = 1; 
  83.           else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 3 ) current_browser = 5; 
  84.           else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 4 ) current_browser = 6; 
  85.           else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 5 ) current_browser = 7; 
  86.           else current_browser = 0;
  87.         }
  88.         
  89.         return current_browser;
  90.     } // end getCurrentBrowserInt
  91.     
  92.     /* ======================================================================
  93.     FUNCTION:    getCurrentBrowser 
  94.      
  95.     INPUT:         none.
  96.     
  97.     RETURN:        none.
  98.     
  99.     DESC:            This function is used with client-side JavaScript to detect
  100.                     the brand and version of the user's browser.  Detects only
  101.                     Netscape and Microsoft browsers.  
  102.     
  103.     PLATFORMS:    Netscape Navigator 3.01 and higher,
  104.                       Microsoft Internet Explorer 3.02 and higher,
  105.     ====================================================================== */
  106.  
  107.     function getCurrentBrowser() {
  108.         var bwr = new String(navigator.appName);
  109.         var ver = parseInt(navigator.appVersion, 10); 
  110.         
  111.         if(ver+"" != "NaN")
  112.         {
  113.           if ( bwr.toUpperCase() == "NETSCAPE" && ver == 5 ) {
  114.               if(this.onNS+"" != "null")
  115.                 this.onNS();
  116.               if(this.onNS5+"" != "null")
  117.                  this.onNS5();
  118.           }
  119.           else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 4 ) {
  120.               if(this.onNS+"" != "null")
  121.                 this.onNS();
  122.               if(this.onNS4+"" != "null")
  123.                 this.onNS4();
  124.           }
  125.           else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 3 ) {
  126.               if(this.onNS+"" != "null")
  127.                 this.onNS();
  128.               if(this.onNS3+"" != "null")
  129.                 this.onNS3();
  130.            }
  131.           else if ( bwr.toUpperCase() == "NETSCAPE" && ver == 2 ) {
  132.               if(this.onNS+"" != "null")
  133.                 this.onNS();
  134.               if(this.onNS2+"" != "null")
  135.                 this.onNS2();
  136.           }
  137.           else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 3 ) {
  138.               if(this.onIE+"" != "null")
  139.                 this.onIE();
  140.               if(this.onIE3+"" != "null")
  141.                 this.onIE3();
  142.           }
  143.           else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 4 ) {
  144.               if(this.onIE+"" != "null")
  145.                 this.onIE();
  146.               if(this.onIE4+"" != "null")
  147.                 this.onIE4();
  148.             }
  149.           else if ( bwr.toUpperCase() == "MICROSOFT INTERNET EXPLORER" && ver == 5 ) {
  150.               if(this.onIE+"" != "null")
  151.                 this.onIE();
  152.               if(this.onIE5+"" != "null")
  153.                   this.onIE5();
  154.           }
  155.           else {
  156.              if(this.onOther+"" != "null")
  157.               this.onOther();
  158.           }
  159.        }
  160.         
  161.     } // end getCurrentBrowser
  162. }