Pre-IE11 versions of Internet Explorer browser have a common pattern/string i.e. "MSIE" within their user agent string. But that is not the case with IE11.
IE11 user agent stringMozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko
IE10 user agent stringMozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
Here is some JavaScript code to identify the version Internet Explorer from user agent string
var isIE11 = navigator.userAgent.match(/Trident.*rv\:11\./); var isIEButNotIE11 = navigator.userAgent.match(/MSIE (\d+\.\d+)/);
This function can be used to get the version number of IE
function IEVersion() {
var ieversion;
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent))
ieversion = new Number(RegExp.$1);
else if (navigator.userAgent.match(/Trident.*rv\:11\./))
ieversion = 11;
return ieversion;
}
No comments:
Post a Comment