user101579
user101579

Reputation: 353

Detect full version internet explorer with javascript?

Is it possible to detect the full version of internet explorer.

navigator.appVersion

navigator.appVersion only gives the major version, for example 9.0 But it doesn't show 9.0.8112.1642...

Upvotes: 2

Views: 941

Answers (5)

regulus
regulus

Reputation: 1622

There is a solution for this below, however only works in 32bit version of Windows: http://www.pinlady.net/PluginDetect/IE/

var e, obj = document.createElement("div"), 
    verIEfull = null; // Full IE version [string/null]

try{ 
    obj.style.behavior = "url(#default#clientcaps)";

    verIEfull = obj.getComponentVersion("{89820200-ECBD-11CF-8B85-00AA005B4383}","componentid").replace(/,/g,".");
}catch(e){};

Upvotes: 1

Tim
Tim

Reputation: 8606

I'd do this:

var IEVersion = 0;
if( window.attachEvent && /MSIE ([\d\.]+)/.exec(navigator.appVersion) ){
    IEVersion = parseInt( RegExp.$1 );
}

It's compact and dodges spoofed UserAgent strings by checking the event model is actually IE first:

Upvotes: 0

Nate Bolam
Nate Bolam

Reputation: 499

Unfortunately you do not have access to the IE build number in JavaScript.

Upvotes: 4

P K
P K

Reputation: 10210

 navigator.userAgent;

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.2)

One possibility is that compare .NET versions with IE minor versions, if we get somewhere that table on microsoft IE documentation.

Upvotes: 0

Dan
Dan

Reputation: 526

From the microsoft development website

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;
}

Upvotes: 0

Related Questions