用javascript检测完整版本的Internet Explorer?
是否有可能检测到Internet Explorer的完整版本。用javascript检测完整版本的Internet Explorer?
navigator.appVersion
navigator.appVersion只给出了主要版本,例如9.0 不过,这并不表明9.0.8112.1642 ...
从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;
}
与OP已经说过的'navigator.appVersion'相比,这并没有给出更多的信息。 – Esailija 2012-01-07 23:17:32
navigator.userAgent;
的Mozilla /4.0(兼容; 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)
一种可能性是将.NET版本与IE小版本进行比较,如果我们在微软IE文档中找到某个表格的话。
“如果我们在Microsoft IE文档的某个表格上找到某个地方,则可以将.NET版本与IE小版本进行比较。” - 我怎么做? – user101579 2012-01-08 03:54:15
不幸的是,您无法访问JavaScript中的IE内部版本号。
我应该这样做:
var IEVersion = 0;
if(window.attachEvent && /MSIE ([\d\.]+)/.exec(navigator.appVersion)){
IEVersion = parseInt(RegExp.$1);
}
它的结构紧凑和闪通过检查事件模型欺骗用户代理字符串其实是IE第一:
也不提供完整版本。不比:navigator.app版本更好 – user101579 2013-06-15 21:55:57
没有针对此之下的解决方案,但是只适用于的Windows的32位版本: 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){};
我不这样只用JavaScript的思考。可能不得不使用类似于ActiveX控件的东西,并从注册表中读取它,因为这是我知道它存储的唯一位置,但我可能是错误的 – 2012-01-07 23:11:04
它会是相当不安全的吗?如果您可以收集确切的版本,则可以轻松地针对已知漏洞进行攻击。 – 2012-01-07 23:21:36
“ActiveX控件并从注册表中读取它” - 如何? – user101579 2012-01-07 23:50:41