Solved

IE11 Check

Posted on 2014-02-27
3
429 Views
Last Modified: 2014-02-27
Hello Experts,

A few years back, I came up with the code below to check if the IE is version 8 or higher.  This worked well for IE 8, 9, and 10, but now for IE11 it comes as false and goes to my else condition.  Why is this, and how can I include IE11 as well?

Thank you.

<script language="javascript">
if(navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substr(0,3) >= '4.0')
{
    self.location = "phone_order.asp";
}
else
{
    self.location = "getIE.asp";
}
</script>

Open in new window

0
Comment
Question by:APD_Toronto
3 Comments
 
LVL 32

Expert Comment

by:Big Monty
ID: 39892260
taken from the MS website, you could do something like this:

function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  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;
}

Open in new window


then wherever you call your code for the check:

<script language="javascript">
if( getInternetExplorerVersion() != -1 )
{
    self.location = "phone_order.asp";
}
else
{
    self.location = "getIE.asp";
}
</script>

Open in new window

0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 39892303
IE11 doesn't use MSIE in its string.

Changing your check line
if((navigator.appName == "Microsoft Internet Explorer" && navigator.appVersion.substr(0,3) >= '4.0')||!!navigator.userAgent.match(/Trident.*rv[ :]*11\./))

Open in new window

0
 

Author Closing Comment

by:APD_Toronto
ID: 39892395
Worked, Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now