如何检测IE11?当我要检测IE时,我使用以下代码:function getInternetExplorerVersion()
{
var rv = -1;
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;
}
function checkVersion()
{
var msg = "You're not using Internet Explorer.";
var ver = getInternetExplorerVersion();
if ( ver > -1 )
{
msg = "You are using IE " + ver;
}
alert( msg );
}但是IE 11正在返回“您没有使用InternetExplorer”。我怎么能发现它?
3 回答
慕斯王
TA贡献1864条经验 获得超2个赞
MSIE
Trident/
navigator.appName
Netscape
function getInternetExplorerVersion(){ var rv = -1; 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 ); } else if (navigator.appName == 'Netscape') { var ua = navigator.userAgent; var re = new RegExp("Trident/.*rv:([0-9]{1,}[\\.0-9]{0,})"); if (re.exec(ua) != null) rv = parseFloat( RegExp.$1 ); } return rv;}console.log('IE version:', getInternetExplorerVersion());
侃侃尔雅
TA贡献1801条经验 获得超16个赞
!(window.ActiveXObject) && "ActiveXObject" in window
"ActiveXObject" in window
- 3 回答
- 0 关注
- 246 浏览
添加回答
举报
0/150
提交
取消