[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

IE11 Check

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…

650 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