js browser detection for IE

js browser detection for IE

My question is the folowing

Is there a solid javascript code to detect if a browser is IE(I don't care about others)

I found some script, but it generates an undefined error in FF.

I edited my question because I found some regex serverside solution for this on this forum It's enough for now.

thanks, Richard

jQuery click function on LI doesn't work in IE


BG images rendering problem in IE
You can find here very useful technique for IE detection using conditional tags..
Enabling/disabling proxy app doesn't work properly with IE
<!DOCTYPE your favorite doc type>       <html>         <head>...</head>          <body>             <!--[if IE]>                     <div id="IEroot">             <![endif]-->                      <p id="IE">This browser is IE.</p>                      <p id="notIE">This browser is not IE.</p>             <!--[if IE]>                     </div>             <![endif]-->         </body>      </html> 
You can use it and put script tag between it to define Javascript action only for IE..
cancel or abort ajax call in ie 6,7,8

What is the syntax to check for element present using Style in IE

Weird CSS issue in IE7


Downloading file using IE from python
Use the .
“download link ” fails in IE
navigator. object.
will give the browser name and.
will give the browser version.. Another one is listed here. Browser detect.


You can check browser either by using Javascript or jQuery.

Javascript provides Navigator object using that you can check like:.
function getBrowserName()   {     if(navigator.appName=="Microsoft Internet Explorer") {         alert("This is " + navigator.appName + " Browser");   } } 
You can look example here: http://www.codegateway.com/2012/09/detect-ie-browser-javascript.html. And jQuery have Browser Object that we can use to detect browser like:.
function getBrowser()  {    if ($.browser.msie) {         alert('IE');     }  } 
See example here: http://www.codegateway.com/2012/09/detect-ie-browser-jquery.html.


<script type="text/javascript"> function getInternetExplorerVersion()  {   var rv = -1;    if (navigator.appName == 'Microsoft Internet Explorer')   {     var ua = navigator.userAgent;     var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");     if (re.exec(ua) != null)       rv = parseFloat( RegExp.$1 );   }   return rv; } function checkVersion() {   var msg = "You're not using Internet Explorer.";   var ver = getInternetExplorerVersion();    if ( ver > -1 )   {     if ( ver >= 8.0 )        msg = "You're using a recent copy of Internet Explorer."     else       msg = "You should upgrade your copy of Internet Explorer.";   }   alert( msg ); } </script> 


navigator.userAgent can be used.

The following detect if browser is IE version <= 9:.
var browserIEInfo = navigator.userAgent.match(/MSIE (([0-9]+)(\.[0-9]+)?)/); if (browserIEInfo === null || parseInt(browserIEInfo[2]) > 9){     // code for non IE or for IE version > 9 }  // code for IE <= 9  

70 out of 100 based on 80 user ratings 430 reviews