Search This Blog

Jan 3, 2012

Detecting IE Browser and It's version

jQuery approach $.browser.msie is the best way to detect if you are viewing in an Internet Explorer browser. In addition, you can also add another jQuery code to detect the version of the IE browser - $.browser.version. Detecting browser is important since there are some jQuery and other framework code that are not working proper in different browsers. In this manner, you can make conditional code depending on the user’s browser.

Using jQuery :
   // less than IE 8 
  if ($.browser.msie && $.browser.version.substr(0,1)<8) {
     //your code here 
  // less than IE 7 
  if ($.browser.msie && $.browser.version.substr(0,1)<7) {
     //your code here 
NOTE: Don't forget to Add jQuery library.

Using conditional comment:

<!--[if lte IE 6]>
<script type="text/javascript">
  var isRunningIE6OrBelow = true;


Anonymous said...

It save's my life.... Thank you.

zamaan said...

thank you , saved me a lot of time.