?
Solved

IE11 Check

Posted on 2014-02-27
3
Medium Priority
?
445 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 34

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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

850 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