Solved

IE11 Check

Posted on 2014-02-27
3
428 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
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…

757 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

18 Experts available now in Live!

Get 1:1 Help Now