Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to find browser details ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 445
    Comment on it

    Jquery have a nice feature to know about browser details. it is deprecated, If the functionality is removed, it will likely be easily accessible using a plugin.

     

    It is safe to use it to determine whether or not to call $(document).ready(), means you can use it without ready() function.  $.browser uses navigator.userAgent to determine the platform

     

    To use it you can find on which browser your code is rendering like browser name version and OS and much more.

     

    Below is script code example -

     

    if(!jQuery.browser){
      jQuery.browser = {};
      jQuery.browser.mozilla = false;
      jQuery.browser.webkit = false;
      jQuery.browser.opera = false;
      jQuery.browser.safari = false;
      jQuery.browser.chrome = false;
      jQuery.browser.msie = false;
      jQuery.browser.android = false;
      jQuery.browser.blackberry = false;
      jQuery.browser.ios = false;
      jQuery.browser.operaMobile = false;
      jQuery.browser.windowsMobile = false;
      jQuery.browser.mobile = false;
    
      var nAgt = navigator.userAgent;
      jQuery.browser.ua = nAgt;
    
      jQuery.browser.name  = navigator.appName;
      jQuery.browser.fullVersion  = ''+parseFloat(navigator.appVersion);
      jQuery.browser.majorVersion = parseInt(navigator.appVersion,10);
      var nameOffset,verOffset,ix;
    
      if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
        jQuery.browser.opera = true;
        jQuery.browser.name = "Opera";
        jQuery.browser.fullVersion = nAgt.substring(verOffset+6);
        if ((verOffset=nAgt.indexOf("Version"))!=-1)
          jQuery.browser.fullVersion = nAgt.substring(verOffset+8);
      }
    
      else if ( (verOffset=nAgt.indexOf("MSIE"))!=-1) {
        jQuery.browser.msie = true;
        jQuery.browser.name = "Microsoft Internet Explorer";
        jQuery.browser.fullVersion = nAgt.substring(verOffset+5);
      }
    
      else if ((verOffset=nAgt.indexOf("Chrome"))!=-1) {
        jQuery.browser.webkit = true;
        jQuery.browser.chrome = true;
        jQuery.browser.name = "Chrome";
        jQuery.browser.fullVersion = nAgt.substring(verOffset+7);
      }
    
      else if ((verOffset=nAgt.indexOf("Safari"))!=-1) {
        jQuery.browser.webkit = true;
        jQuery.browser.safari = true;
        jQuery.browser.name = "Safari";
        jQuery.browser.fullVersion = nAgt.substring(verOffset+7);
        if ((verOffset=nAgt.indexOf("Version"))!=-1)
          jQuery.browser.fullVersion = nAgt.substring(verOffset+8);
      }
    
      else if ((verOffset=nAgt.indexOf("AppleWebkit"))!=-1) {
        jQuery.browser.webkit = true;
        jQuery.browser.name = "Safari";
        jQuery.browser.fullVersion = nAgt.substring(verOffset+7);
        if ((verOffset=nAgt.indexOf("Version"))!=-1)
          jQuery.browser.fullVersion = nAgt.substring(verOffset+8);
      }
    
      else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
        jQuery.browser.mozilla = true;
        jQuery.browser.name = "Firefox";
        jQuery.browser.fullVersion = nAgt.substring(verOffset+8);
      }
    
      else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) ){
        jQuery.browser.name = nAgt.substring(nameOffset,verOffset);
        jQuery.browser.fullVersion = nAgt.substring(verOffset+1);
        if (jQuery.browser.name.toLowerCase()==jQuery.browser.name.toUpperCase()) {
          jQuery.browser.name = navigator.appName;
        }
      }
    
      jQuery.browser.android = (/Android/i).test(nAgt);
      jQuery.browser.blackberry = (/BlackBerry/i).test(nAgt);
      jQuery.browser.ios = (/iPhone|iPad|iPod/i).test(nAgt);
      jQuery.browser.operaMobile = (/Opera Mini/i).test(nAgt);
      jQuery.browser.windowsMobile = (/IEMobile/i).test(nAgt);
      jQuery.browser.mobile = jQuery.browser.android || jQuery.browser.blackberry || jQuery.browser.ios || jQuery.browser.windowsMobile || jQuery.browser.operaMobile;
    
      if ((ix=jQuery.browser.fullVersion.indexOf(";"))!=-1)
        jQuery.browser.fullVersion=jQuery.browser.fullVersion.substring(0,ix);
      if ((ix=jQuery.browser.fullVersion.indexOf(" "))!=-1)
        jQuery.browser.fullVersion=jQuery.browser.fullVersion.substring(0,ix);
    
      jQuery.browser.majorVersion = parseInt(''+jQuery.browser.fullVersion,10);
      if (isNaN(jQuery.browser.majorVersion)) {
        jQuery.browser.fullVersion  = ''+parseFloat(navigator.appVersion);
        jQuery.browser.majorVersion = parseInt(navigator.appVersion,10);
      }
      jQuery.browser.version = jQuery.browser.majorVersion;
    }
    
    var txt = '' + 'navigator.appName = ' + navigator.appName + '<br>' + 'navigator.userAgent = ' + navigator.userAgent + '<br><br><br>' + 'jQuery.browser.name  = ' + jQuery.browser.name + '<br>' + 'jQuery.browser.fullVersion  = ' + jQuery.browser.fullVersion + '<br>' + 'jQuery.browser.version = ' + jQuery.browser.version + '<br>' + 'jQuery.browser.majorVersion = ' + jQuery.browser.majorVersion + '<br><br><br>' + 'jQuery.browser.msie = ' + jQuery.browser.msie + '<br>' + 'jQuery.browser.mozilla = ' + jQuery.browser.mozilla + '<br>' + 'jQuery.browser.opera = ' + jQuery.browser.opera + '<br>' + 'jQuery.browser.chrome = ' + jQuery.browser.chrome + '<br>'+ 'jQuery.browser.webkit = ' + jQuery.browser.webkit + '<br>' + '<br>' + 'jQuery.browser.android = ' + jQuery.browser.android + '<br>' + 'jQuery.browser.blackberry = ' + jQuery.browser.blackberry + '<br>' + 'jQuery.browser.ios = ' + jQuery.browser.ios + '<br>' +  'jQuery.browser.operaMobile = ' + jQuery.browser.operaMobile + '<br>' + 'jQuery.browser.windowsMobile = ' + jQuery.browser.windowsMobile + '<br>' + 'jQuery.browser.mobile = ' + jQuery.browser.mobile;
    
    $("#show").html(txt);

    Note - You should run on your end for more clarification -

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: