![](/img/trans.png)
[英]Is it possible to detect full Internet Explorer 11 build version using a script?
[英]Detect full version internet explorer with javascript?
是否有可能檢測到Internet Explorer的完整版本。
navigator.appVersion
navigator.appVersion僅提供主要版本,例如9.0,但未顯示9.0.8112.1642 ...
不幸的是,您無權訪問JavaScript中的IE內部版本號。
下面有一個解決方案,但是僅適用於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){};
我會這樣做:
var IEVersion = 0;
if( window.attachEvent && /MSIE ([\d\.]+)/.exec(navigator.appVersion) ){
IEVersion = parseInt( RegExp.$1 );
}
它緊湊且通過檢查事件模型實際上是否是IE來避開欺騙性的UserAgent字符串:
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;
}
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)
一種可能性是,如果我們在Microsoft IE文檔中找到該表格,則將.NET版本與IE次要版本進行比較。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.