Extjs4中判断浏览器和操作系统

  Ext.onReady(function(){
   if (Ext.isChrome){
    Ext.Msg.alert("浏览器检测","你使用的是Chrome");
   }
   /**
    *检测IE
    *
    */
   if (Ext.isIE){
    Ext.Msg.alert("浏览器检测","你使用的是IE");
   }
   if (Ext.isIE6){
    Ext.Msg.alert("浏览器检测","你使用的是IE");
   }
   if (Ext.isIE7){
    Ext.Msg.alert("浏览器检测","你使用的是IE7");
   }
   if (Ext.isIE8){
    Ext.Msg.alert("浏览器检测","你使用的是IE8");
   }
   /**
    *像火狐和MOzilla这样的浏览器使用的是Gecko引擎,所以检测他们需要使用Ext.isGecko, Ext.isGecko2, Ext.isGecko3
    *The browsers such as Mozilla and Firefox that use the Gecko rendering engine are
    *detected with Ext.isGecko, Ext.isGecko2, and Ext.isGecko3:
    */

    if (Ext.isGecko) {
    browser = "Gecko";
    }
    if (Ext.isGecko2) {
    browser = "Gecko2";
    }
    if (Ext.isGecko3) {
    browser = "We like Firefox!";
    }
    /**
     *检测浏览器是否为Opera
     *
     *
     */   
    if (Ext.isOpera) {
     Ext.Msg.alert("浏览器检测","你使用的是Opera");
    }
    if (Ext.isSafari) {
    browser = "Safari";
    }
    if (Ext.isSafari2) {
    browser = "Safari2";
    }
    if (Ext.isSafari3) {
    browser = "Safari3";
    }
    if (Ext.isSafari4) {
    browser = "Safari4";
    }
   
    //******************************************
    /**
     *检测操作系统
     *
     */
     if (Ext.isLinux) {
     platform = "Linux";
     Ext.Msg.alert("系统","您使用是Linux系统");
     }

    if (Ext.isMac) {
     platform = "Mac";
     Ext.Msg.alert("系统","您使用是Mac系统");
    }
   if (Ext.isWindows) {
     platform = "Windows ";
     Ext.Msg.alert("系统","您使用是Window系统");
   }
   /**
    *Adobe's Air is detected with Ext.isAir:
    */

   if (Ext.isAir) {
     platform = "Air";
   }
   /**
    *Extjs获取的浏览器值和运行平台值都是通过解析JavaScript的navigator对象的userAgent属性来获取的
    *the values for Ext JS's browser and platform type flags are all obtained
    *from parsing the value of the userAgent property of the JavaScript navigator object
    *
    */
   /*
    *
    *ext-all.js代码中有相关源码
    */
  });

你可能感兴趣的:(linux,浏览器,IE,ext,AIR)