Browser Detection (Mobile/MSIE)

Unmaintained Browser Detection (Mobile/MSIE) 1.3.3

No permission to download
How to use the new conditionals?
Don't forget: a tablet is also detected as mobile

IN TEMPLATES

  • Before to start:
    The visitor object is not available in the css templates, so you need to use the conditionnal in the "normal" template and include a special css template with custom styles.

    Example taken from the TinyMCE Quattro addon:
    HTML:
    <xen:if is="{$visitor.getBrowser.IEis} != 7">
       <xen:require css="tiny_quattro_editor.css" />
    <xen:else />
       <xen:require css="tiny_quattro_editor_ie7.css" />
    </xen:if>
  • Examples:
    Code:
      <xen:if is="{$visitor.getBrowser.isIE}">
      {xen:if "{$visitor.getBrowser.IEis} == 9", "You're using Internet Explorer 9", "You're using Internet Explorer {$visitor.getBrowser.IEis}"}
      <xen:elseif is="{$visitor.getBrowser.isMobile}" />
      You're using a mobile device.{xen:if "{$visitor.getBrowser.isTablet}", "This Mobile device is a tablet"}
      <xen:else />
      Hello world !
      </xen:if>
  • Variables
    (if you want to check: {xen:helper dump, $visitor.getBrowser}):

    Code:
      $visitor.getBrowser.isIE
      $visitor.getBrowser.IEis
      $visitor.getBrowser.isMobile
      $visitor.getBrowser.isTablet
    
      //Phones
      $visitor.getBrowser.mobile.phones.isiPhone
      $visitor.getBrowser.mobile.phones.isBlackBerry
      $visitor.getBrowser.mobile.phones.isHTC
      $visitor.getBrowser.mobile.phones.isNexus
      $visitor.getBrowser.mobile.phones.isDellStreak
      $visitor.getBrowser.mobile.phones.isMotorola
      $visitor.getBrowser.mobile.phones.isSamsung
      $visitor.getBrowser.mobile.phones.isSony
      $visitor.getBrowser.mobile.phones.isAsus
      $visitor.getBrowser.mobile.phones.isPalm
      $visitor.getBrowser.mobile.phones.isFly
      $visitor.getBrowser.mobile.phones.isLG
      $visitor.getBrowser.mobile.phones.isMicromax
      $visitor.getBrowser.mobile.phones.isiMobile
      $visitor.getBrowser.mobile.phones.isSimValley
      $visitor.getBrowser.mobile.phones.isWolfgang
      $visitor.getBrowser.mobile.phones.isAlcatel
      $visitor.getBrowser.mobile.phones.isNintendo
      $visitor.getBrowser.mobile.phones.isAmoi
      $visitor.getBrowser.mobile.phones.isINQ
      $visitor.getBrowser.mobile.phones.isWiko
      $visitor.getBrowser.mobile.phones.isGenericPhone
    
      //Tablets
      $visitor.getBrowser.mobile.tablets.isBlackBerryTablet
      $visitor.getBrowser.mobile.tablets.isiPad
      $visitor.getBrowser.mobile.tablets.isKindle
      $visitor.getBrowser.mobile.tablets.isSamsungTablet
      $visitor.getBrowser.mobile.tablets.isHTCtablet
      $visitor.getBrowser.mobile.tablets.isMotorolaTablet
      $visitor.getBrowser.mobile.tablets.isAsusTablet
      $visitor.getBrowser.mobile.tablets.isNookTablet
      $visitor.getBrowser.mobile.tablets.isAcerTablet
      $visitor.getBrowser.mobile.tablets.isYarvikTablet
      $visitor.getBrowser.mobile.tablets.isToshibaTablet
      $visitor.getBrowser.mobile.tablets.isCubeTablet
      $visitor.getBrowser.mobile.tablets.isCobyTablet
      $visitor.getBrowser.mobile.tablets.isSMiTTablet
      $visitor.getBrowser.mobile.tablets.isRockChipTablet
      $visitor.getBrowser.mobile.tablets.isTelstraTablet
      $visitor.getBrowser.mobile.tablets.isPlaystationTablet
      $visitor.getBrowser.mobile.tablets.isNabiTablet
      $visitor.getBrowser.mobile.tablets.isNecTablet
      $visitor.getBrowser.mobile.tablets.isHuaweiTablet
      $visitor.getBrowser.mobile.tablets.isbqTablet
      $visitor.getBrowser.mobile.tablets.isFlyTablet
      $visitor.getBrowser.mobile.tablets.isLGTablet
      $visitor.getBrowser.mobile.tablets.isSurfaceTablet
      $visitor.getBrowser.mobile.tablets.isHPTablet
      $visitor.getBrowser.mobile.tablets.isFujitsuTablet
      $visitor.getBrowser.mobile.tablets.isPrestigioTablet
      $visitor.getBrowser.mobile.tablets.isLenovoTablet
      $visitor.getBrowser.mobile.tablets.isIntensoTablet
      $visitor.getBrowser.mobile.tablets.isIRUTablet
      $visitor.getBrowser.mobile.tablets.isMegafonTablet
      $visitor.getBrowser.mobile.tablets.isEbodaTablet
      $visitor.getBrowser.mobile.tablets.isAllViewTablet
      $visitor.getBrowser.mobile.tablets.isSonyTablet
      $visitor.getBrowser.mobile.tablets.isMIDTablet
      $visitor.getBrowser.mobile.tablets.isPantechTablet
      $visitor.getBrowser.mobile.tablets.isBronchoTablet
      $visitor.getBrowser.mobile.tablets.isVersusTablet
      $visitor.getBrowser.mobile.tablets.isZyncTablet
      $visitor.getBrowser.mobile.tablets.isPositivoTablet
      $visitor.getBrowser.mobile.tablets.isKoboTablet
      $visitor.getBrowser.mobile.tablets.isDanewTablet
      $visitor.getBrowser.mobile.tablets.isTexetTablet
      $visitor.getBrowser.mobile.tablets.isTrekstorTablet
      $visitor.getBrowser.mobile.tablets.isPyleAudioTablet
      $visitor.getBrowser.mobile.tablets.isAdvanTablet
      $visitor.getBrowser.mobile.tablets.isDanyTechTablet
      $visitor.getBrowser.mobile.tablets.isGalapadTablet
      $visitor.getBrowser.mobile.tablets.isMicromaxTablet
      $visitor.getBrowser.mobile.tablets.isKarbonnTablet
      $visitor.getBrowser.mobile.tablets.isAllFineTablet
      $visitor.getBrowser.mobile.tablets.isPROSCANTablet
      $visitor.getBrowser.mobile.tablets.isYONESTablet
      $visitor.getBrowser.mobile.tablets.isChangJiaTablet
      $visitor.getBrowser.mobile.tablets.isGUTablet
      $visitor.getBrowser.mobile.tablets.isPointOfViewTablet
      $visitor.getBrowser.mobile.tablets.isOvermaxTablet
      $visitor.getBrowser.mobile.tablets.isHCLTablet
      $visitor.getBrowser.mobile.tablets.isDPSTablet
      $visitor.getBrowser.mobile.tablets.isVistureTablet
      $visitor.getBrowser.mobile.tablets.isCrestaTablet
      $visitor.getBrowser.mobile.tablets.isMediatekTablet
      $visitor.getBrowser.mobile.tablets.isConcordeTablet
      $visitor.getBrowser.mobile.tablets.isGoCleverTablet
      $visitor.getBrowser.mobile.tablets.isModecomTablet
      $visitor.getBrowser.mobile.tablets.isVoninoTablet
      $visitor.getBrowser.mobile.tablets.isECSTablet
      $visitor.getBrowser.mobile.tablets.isStorexTablet
      $visitor.getBrowser.mobile.tablets.isVodafoneTablet
      $visitor.getBrowser.mobile.tablets.isEssentielBTablet
      $visitor.getBrowser.mobile.tablets.isRossMoorTablet
      $visitor.getBrowser.mobile.tablets.isiMobileTablet
      $visitor.getBrowser.mobile.tablets.isTolinoTablet
      $visitor.getBrowser.mobile.tablets.isHudl
      $visitor.getBrowser.mobile.tablets.isAudioSonicTablet
      $visitor.getBrowser.mobile.tablets.isAMPETablet
      $visitor.getBrowser.mobile.tablets.isSkkTablet
      $visitor.getBrowser.mobile.tablets.isTecnoTablet
      $visitor.getBrowser.mobile.tablets.isJXDTablet
      $visitor.getBrowser.mobile.tablets.isiJoyTablet
      $visitor.getBrowser.mobile.tablets.isFX2Tablet
      $visitor.getBrowser.mobile.tablets.isXoroTablet
      $visitor.getBrowser.mobile.tablets.isViewsonicTablet
      $visitor.getBrowser.mobile.tablets.isOdysTablet
      $visitor.getBrowser.mobile.tablets.isCaptivaTablet
      $visitor.getBrowser.mobile.tablets.isIconbitTablet
      $visitor.getBrowser.mobile.tablets.isTeclastTablet
      $visitor.getBrowser.mobile.tablets.isJaytechTablet
      $visitor.getBrowser.mobile.tablets.isBlaupunktTablet
      $visitor.getBrowser.mobile.tablets.isDigmaTablet
      $visitor.getBrowser.mobile.tablets.isEvolioTablet
      $visitor.getBrowser.mobile.tablets.isLavaTablet
      $visitor.getBrowser.mobile.tablets.isCelkonTablet
      $visitor.getBrowser.mobile.tablets.isMiTablet
      $visitor.getBrowser.mobile.tablets.isNibiruTablet
      $visitor.getBrowser.mobile.tablets.isNexoTablet
      $visitor.getBrowser.mobile.tablets.isUbislateTablet
      $visitor.getBrowser.mobile.tablets.isPocketBookTablet
      $visitor.getBrowser.mobile.tablets.isOndaTablet
      $visitor.getBrowser.mobile.tablets.isAocTablet
      $visitor.getBrowser.mobile.tablets.isWolderTablet
      $visitor.getBrowser.mobile.tablets.issLeaderTablet
      $visitor.getBrowser.mobile.tablets.isGenericTablet
    
      //Os
      $visitor.getBrowser.mobile.os.isAndroidOS
      $visitor.getBrowser.mobile.os.isBlackBerryOS
      $visitor.getBrowser.mobile.os.isPalmOS
      $visitor.getBrowser.mobile.os.isSymbianOS
      $visitor.getBrowser.mobile.os.isWindowsMobileOS
      $visitor.getBrowser.mobile.os.isiOS
      $visitor.getBrowser.mobile.os.isJavaOS
      $visitor.getBrowser.mobile.os.isNokiaOS
      $visitor.getBrowser.mobile.os.iswebOS
      $visitor.getBrowser.mobile.os.isbadaOS
      $visitor.getBrowser.mobile.os.isBREWOS
    
      //Browsers
      //Doesn't work well because broswers let users select which useragent they want to use; ie: Dolfin (Dolphin)
      $visitor.getBrowser.mobile.browser.isChrome
      $visitor.getBrowser.mobile.browser.isDolfin
      $visitor.getBrowser.mobile.browser.isOpera
      $visitor.getBrowser.mobile.browser.isSkyfire
      $visitor.getBrowser.mobile.browser.isIE
      $visitor.getBrowser.mobile.browser.isFirefox
      $visitor.getBrowser.mobile.browser.isBolt
      $visitor.getBrowser.mobile.browser.isTeaShark
      $visitor.getBrowser.mobile.browser.isBlazer
      $visitor.getBrowser.mobile.browser.isSafari
      $visitor.getBrowser.mobile.browser.isDiigoBrowser
      $visitor.getBrowser.mobile.browser.isPuffin
      $visitor.getBrowser.mobile.browser.isMidori
      $visitor.getBrowser.mobile.browser.isMercury
      $visitor.getBrowser.mobile.browser.isbaiduboxapp
      $visitor.getBrowser.mobile.browser.isbaidubrowser
      $visitor.getBrowser.mobile.browser.isObigoBrowser
      $visitor.getBrowser.mobile.browser.isNetFront
      $visitor.getBrowser.mobile.browser.isGenericBrowser

IN PHP
  • Get the $visitor object:
    Code:
      $visitor = XenForo_Visitor::getInstance();
  • Examples:
    Code:
      if($visitor->getBrowser['isIE'])
      {
      if($visitor->getBrowser['IEis'] == 9)
      {
      echo "You're using Internet Explorer 9";
      }
      else
      {
      echo "You're using Internet Explorer " . $visitor->getBrowser['IEis'];
      }
      }
      elseif ($visitor->getBrowser['isMobile'])
      {
      $builder = "You're using a mobile device. ";
    
      if($visitor->getBrowser['isTablet'])
      {
      $builder .= "This Mobile device is a tablet";
      }
    
      echo $builder;
      }
      else
      {
      echo "Hello World !";
      }
  • Variables:

    PHP:
      $visitor->getBrowser['isIE']
      $visitor->getBrowser['IEis']
      $visitor->getBrowser['isMobile']
      $visitor->getBrowser['isTablet']
    
      //Phones
      $visitor->getBrowser['mobile']['phones']['isiPhone']
      $visitor->getBrowser['mobile']['phones']['isBlackBerry']
      $visitor->getBrowser['mobile']['phones']['isHTC']
      $visitor->getBrowser['mobile']['phones']['isNexus']
      $visitor->getBrowser['mobile']['phones']['isDellStreak']
      $visitor->getBrowser['mobile']['phones']['isMotorola']
      $visitor->getBrowser['mobile']['phones']['isSamsung']
      $visitor->getBrowser['mobile']['phones']['isSony']
      $visitor->getBrowser['mobile']['phones']['isAsus']
      $visitor->getBrowser['mobile']['phones']['isPalm']
      $visitor->getBrowser['mobile']['phones']['isFly']
      $visitor->getBrowser['mobile']['phones']['isLG']
      $visitor->getBrowser['mobile']['phones']['isMicromax']
      $visitor->getBrowser['mobile']['phones']['isiMobile']
      $visitor->getBrowser['mobile']['phones']['isSimValley']
      $visitor->getBrowser['mobile']['phones']['isWolfgang']
      $visitor->getBrowser['mobile']['phones']['isAlcatel']
      $visitor->getBrowser['mobile']['phones']['isNintendo']
      $visitor->getBrowser['mobile']['phones']['isAmoi']
      $visitor->getBrowser['mobile']['phones']['isINQ']
      $visitor->getBrowser['mobile']['phones']['isWiko']
      $visitor->getBrowser['mobile']['phones']['isGenericPhone']
    
      //Tablets
      $visitor->getBrowser['mobile']['tablets']['isBlackBerryTablet']
      $visitor->getBrowser['mobile']['tablets']['isiPad']
      $visitor->getBrowser['mobile']['tablets']['isKindle']
      $visitor->getBrowser['mobile']['tablets']['isSamsungTablet']
      $visitor->getBrowser['mobile']['tablets']['isHTCtablet']
      $visitor->getBrowser['mobile']['tablets']['isMotorolaTablet']
      $visitor->getBrowser['mobile']['tablets']['isAsusTablet']
      $visitor->getBrowser['mobile']['tablets']['isNookTablet']
      $visitor->getBrowser['mobile']['tablets']['isAcerTablet']
      $visitor->getBrowser['mobile']['tablets']['isYarvikTablet']
      $visitor->getBrowser['mobile']['tablets']['isToshibaTablet']
      $visitor->getBrowser['mobile']['tablets']['isCubeTablet']
      $visitor->getBrowser['mobile']['tablets']['isCobyTablet']
      $visitor->getBrowser['mobile']['tablets']['isSMiTTablet']
      $visitor->getBrowser['mobile']['tablets']['isRockChipTablet']
      $visitor->getBrowser['mobile']['tablets']['isTelstraTablet']
      $visitor->getBrowser['mobile']['tablets']['isPlaystationTablet']
      $visitor->getBrowser['mobile']['tablets']['isNabiTablet']
      $visitor->getBrowser['mobile']['tablets']['isNecTablet']
      $visitor->getBrowser['mobile']['tablets']['isHuaweiTablet']
      $visitor->getBrowser['mobile']['tablets']['isbqTablet']
      $visitor->getBrowser['mobile']['tablets']['isFlyTablet']
      $visitor->getBrowser['mobile']['tablets']['isLGTablet']
      $visitor->getBrowser['mobile']['tablets']['isSurfaceTablet']
      $visitor->getBrowser['mobile']['tablets']['isHPTablet']
      $visitor->getBrowser['mobile']['tablets']['isFujitsuTablet']
      $visitor->getBrowser['mobile']['tablets']['isPrestigioTablet']
      $visitor->getBrowser['mobile']['tablets']['isLenovoTablet']
      $visitor->getBrowser['mobile']['tablets']['isIntensoTablet']
      $visitor->getBrowser['mobile']['tablets']['isIRUTablet']
      $visitor->getBrowser['mobile']['tablets']['isMegafonTablet']
      $visitor->getBrowser['mobile']['tablets']['isEbodaTablet']
      $visitor->getBrowser['mobile']['tablets']['isAllViewTablet']
      $visitor->getBrowser['mobile']['tablets']['isSonyTablet']
      $visitor->getBrowser['mobile']['tablets']['isMIDTablet']
      $visitor->getBrowser['mobile']['tablets']['isPantechTablet']
      $visitor->getBrowser['mobile']['tablets']['isBronchoTablet']
      $visitor->getBrowser['mobile']['tablets']['isVersusTablet']
      $visitor->getBrowser['mobile']['tablets']['isZyncTablet']
      $visitor->getBrowser['mobile']['tablets']['isPositivoTablet']
      $visitor->getBrowser['mobile']['tablets']['isKoboTablet']
      $visitor->getBrowser['mobile']['tablets']['isDanewTablet']
      $visitor->getBrowser['mobile']['tablets']['isTexetTablet']
      $visitor->getBrowser['mobile']['tablets']['isTrekstorTablet']
      $visitor->getBrowser['mobile']['tablets']['isPyleAudioTablet']
      $visitor->getBrowser['mobile']['tablets']['isAdvanTablet']
      $visitor->getBrowser['mobile']['tablets']['isDanyTechTablet']
      $visitor->getBrowser['mobile']['tablets']['isGalapadTablet']
      $visitor->getBrowser['mobile']['tablets']['isMicromaxTablet']
      $visitor->getBrowser['mobile']['tablets']['isKarbonnTablet']
      $visitor->getBrowser['mobile']['tablets']['isAllFineTablet']
      $visitor->getBrowser['mobile']['tablets']['isPROSCANTablet']
      $visitor->getBrowser['mobile']['tablets']['isYONESTablet']
      $visitor->getBrowser['mobile']['tablets']['isChangJiaTablet']
      $visitor->getBrowser['mobile']['tablets']['isGUTablet']
      $visitor->getBrowser['mobile']['tablets']['isPointOfViewTablet']
      $visitor->getBrowser['mobile']['tablets']['isOvermaxTablet']
      $visitor->getBrowser['mobile']['tablets']['isHCLTablet']
      $visitor->getBrowser['mobile']['tablets']['isDPSTablet']
      $visitor->getBrowser['mobile']['tablets']['isVistureTablet']
      $visitor->getBrowser['mobile']['tablets']['isCrestaTablet']
      $visitor->getBrowser['mobile']['tablets']['isMediatekTablet']
      $visitor->getBrowser['mobile']['tablets']['isConcordeTablet']
      $visitor->getBrowser['mobile']['tablets']['isGoCleverTablet']
      $visitor->getBrowser['mobile']['tablets']['isModecomTablet']
      $visitor->getBrowser['mobile']['tablets']['isVoninoTablet']
      $visitor->getBrowser['mobile']['tablets']['isECSTablet']
      $visitor->getBrowser['mobile']['tablets']['isStorexTablet']
      $visitor->getBrowser['mobile']['tablets']['isVodafoneTablet']
      $visitor->getBrowser['mobile']['tablets']['isEssentielBTablet']
      $visitor->getBrowser['mobile']['tablets']['isRossMoorTablet']
      $visitor->getBrowser['mobile']['tablets']['isiMobileTablet']
      $visitor->getBrowser['mobile']['tablets']['isTolinoTablet']
      $visitor->getBrowser['mobile']['tablets']['isHudl']
      $visitor->getBrowser['mobile']['tablets']['isAudioSonicTablet']
      $visitor->getBrowser['mobile']['tablets']['isAMPETablet']
      $visitor->getBrowser['mobile']['tablets']['isSkkTablet']
      $visitor->getBrowser['mobile']['tablets']['isTecnoTablet']
      $visitor->getBrowser['mobile']['tablets']['isJXDTablet']
      $visitor->getBrowser['mobile']['tablets']['isiJoyTablet']
      $visitor->getBrowser['mobile']['tablets']['isFX2Tablet']
      $visitor->getBrowser['mobile']['tablets']['isXoroTablet']
      $visitor->getBrowser['mobile']['tablets']['isViewsonicTablet']
      $visitor->getBrowser['mobile']['tablets']['isOdysTablet']
      $visitor->getBrowser['mobile']['tablets']['isCaptivaTablet']
      $visitor->getBrowser['mobile']['tablets']['isIconbitTablet']
      $visitor->getBrowser['mobile']['tablets']['isTeclastTablet']
      $visitor->getBrowser['mobile']['tablets']['isJaytechTablet']
      $visitor->getBrowser['mobile']['tablets']['isBlaupunktTablet']
      $visitor->getBrowser['mobile']['tablets']['isDigmaTablet']
      $visitor->getBrowser['mobile']['tablets']['isEvolioTablet']
      $visitor->getBrowser['mobile']['tablets']['isLavaTablet']
      $visitor->getBrowser['mobile']['tablets']['isCelkonTablet']
      $visitor->getBrowser['mobile']['tablets']['isMiTablet']
      $visitor->getBrowser['mobile']['tablets']['isNibiruTablet']
      $visitor->getBrowser['mobile']['tablets']['isNexoTablet']
      $visitor->getBrowser['mobile']['tablets']['isUbislateTablet']
      $visitor->getBrowser['mobile']['tablets']['isPocketBookTablet']
      $visitor->getBrowser['mobile']['tablets']['isOndaTablet']
      $visitor->getBrowser['mobile']['tablets']['isAocTablet']
      $visitor->getBrowser['mobile']['tablets']['isWolderTablet']
      $visitor->getBrowser['mobile']['tablets']['isLeaderTablet']
      $visitor->getBrowser['mobile']['tablets']['isGenericTablet']
    
      //Os
      $visitor->getBrowser['mobile']['os']['isAndroidOS']
      $visitor->getBrowser['mobile']['os']['isBlackBerryOS']
      $visitor->getBrowser['mobile']['os']['isPalmOS']
      $visitor->getBrowser['mobile']['os']['isSymbianOS']
      $visitor->getBrowser['mobile']['os']['isWindowsMobileOS']
      $visitor->getBrowser['mobile']['os']['isiOS']
      $visitor->getBrowser['mobile']['os']['isJavaOS']
      $visitor->getBrowser['mobile']['os']['isNokiaOS']
      $visitor->getBrowser['mobile']['os']['iswebOS']
      $visitor->getBrowser['mobile']['os']['isbadaOS']
      $visitor->getBrowser['mobile']['os']['isBREWOS']
    
      //Browsers
      //Doesn't work well because broswers let users select which useragent they want to use; ie: Dolfin (Dolphin)
      $visitor->getBrowser['mobile']['browser']['isChrome']
      $visitor->getBrowser['mobile']['browser']['isDolfin']
      $visitor->getBrowser['mobile']['browser']['isOpera']
      $visitor->getBrowser['mobile']['browser']['isSkyfire']
      $visitor->getBrowser['mobile']['browser']['isIE']
      $visitor->getBrowser['mobile']['browser']['isFirefox']
      $visitor->getBrowser['mobile']['browser']['isBolt']
      $visitor->getBrowser['mobile']['browser']['isTeaShark']
      $visitor->getBrowser['mobile']['browser']['isBlazer']
      $visitor->getBrowser['mobile']['browser']['isSafari']
      $visitor->getBrowser['mobile']['browser']['isMidori']
      $visitor->getBrowser['mobile']['browser']['isMercury']
      $visitor->getBrowser['mobile']['browser']['isbaiduboxapp']
      $visitor->getBrowser['mobile']['browser']['isbaidubrowser']
      $visitor->getBrowser['mobile']['browser']['isObigoBrowser']
      $visitor->getBrowser['mobile']['browser']['isNetFront']
      $visitor->getBrowser['mobile']['browser']['isGenericBrowser']
Top