Last Updated: February 25, 2016
·
408
· benjamincharity

Return major version of IE.

Code directly taken from AngularJS: http://bnj.bz/2h2f2n3z3N2O

I just thought it was worth sharing...

// define a couple of functions to
// make things a bit cleaner
var lowercase = function(string){
  return isString(string) ? string.toLowerCase() : string;
};
function isString(value){
  return typeof value == 'string';
}

// test for the major version of IE
var msie = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]);

// Results will return a simple integer, e.g. '10'