Detect if any kind of IE (MSIE)


This question already has an answer here:


This works for me to detect any Version of the IE 5-11 (Internet Explorer) (Aug/05/2014):

if (navigator.appName == 'Microsoft Internet Explorer' ||  !!(navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/rv:11/)) || (typeof $.browser !== "undefined" && $.browser.msie == 1))
  alert("Please dont use IE.");

This is because each release of Internet Explorer updates the user-agent string.

MSIE tokens have been removed in Internet Explorer 11 and $.browser uses navigator.userAgent to determine the platform and it is removed in jQuery 1.9.

You can use following code to determine the browser with pure java-script.

var isIE = !!navigator.userAgent.match(/Trident/g) || !!navigator.userAgent.match(/MSIE/g);

 alert("Not IE");   


if you are not interessted wich version of ie the user currently use you can try get it work with detecting if the browser supports the Conditional Compilation Statements

    // You use IE. That´s no good.
    alert("oh my god");

You can use conditional compilation , e.g.

var isIE = false;
/*@cc_on isIE = true; @*/

But note that IE11 doesn't observe this in Standards Mode. User Agent sniffing is generally a bad idea, but as IE becomes more standards-compliant, it also becomes harder to detect (hopefully also meaning less need to)

For IE> 10 which is currently IE 11, user-agent carries something in Browser's HTTP request headers

Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko

You can put a check on "rv:11.0" for version 11. Let me know if you need code for this.

I've found (maybe in SO) in the past this script and it worked for me (IE 10 too)

<![if IE]>
<script type='text/javascript'>
var bIsIE = 1;

and then

if (typeof (bIsIE) != 'undefined')
    //IE :(
    //NOT IE :)

Need Your Help

UITapGestureRecognizer in UIScrollView subview

objective-c uiscrollview uiimageview uigesturerecognizer

I'm trying to use a single tap recognizer in an imageView (that is also a scrollView child).

EF 4.1 - Model Relationships entity-framework-4 entity-relationship ef-code-first entity-framework-4.1

I'm trying to create a quick ASP.NET MVC 3 application using the RC version of EF 4.1. I have two models: