Detect Browsers using jQuery

jQuery provides a property to detect the browser. It works well for IE, mozilla, Safari and opera browser but it doesn’t work for Google Chrome. Below jQuery code gives you an idea about $.browser property.

 

$(document).ready(function() {
  if ($.browser.mozilla && $.browser.version >= "2.0" ){
   alert('Mozilla above 1.9');
  }

  if( $.browser.safari ){
   alert('Safari');
  }

  if( $.browser.opera){
   alert('Opera');
  }

  if ($.browser.msie && $.browser.version <= 6 ){
   alert('IE 6 or below version');
  }

  if ($.browser.msie && $.browser.version > 6){
   alert('IE above 6');
  }
});

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s