Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect if any kind of IE (MSIE) [duplicate]

I dont want to allow users to access my site with Microsoft Internetexplorer (ANY VERSION).

What I´ve found so far was to detect if it´s lower or equal version 10.

A very annoing thing: Internetexplorer >v10 doesn´t admit to be a InternetExplorer.

What i´ve found and tried so far:

if(navigator.appVersion.indexOf("MSIE")!=-1){ alert("You use IE. That´s no good."); } 

or

if ( $.browser.msie ) { alert( $.browser.version ); } 

and

http://msdn.microsoft.com/en-us/library/ie/ms537509%28v=vs.85%29.aspx

I would use any solution if it is in javascript, jquery or php if there is one.

like image 772
WorkersGonnaWork Avatar asked Jul 21 '14 08:07

WorkersGonnaWork


2 Answers

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."); } 
like image 170
Top Questions Avatar answered Sep 28 '22 00:09

Top Questions


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);  if(isIE){  alert("IE");  } else{  alert("Not IE");    } 

Thanks!

like image 33
Saranga Avatar answered Sep 28 '22 00:09

Saranga