Solved

IE11 Check

Posted on 2014-02-27
3
433 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 33

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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
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…

690 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