Mou*_*jli 8 html javascript css jquery internet-explorer
我如何检查用户浏览器是否为IE?我在这里有这个代码,但它不起作用.
if($.browser.msie && $.browser.version <= 9)
{
alert('You Are Using An Outdated Browser! Switch To Chrome Or FireFox.');
}
Run Code Online (Sandbox Code Playgroud)
Mot*_*tie 16
试试James Padolsey的这个解决方案:
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
// And to detect the version:
// ie === 6 // IE6
// ie> 7 // IE8, IE9 ...
// ie <9 // Anything less than IE9
// ----------------------------------------------------------
var ie = (function(){
var undef, v = 3, div = document.createElement('div');
while (
div.innerHTML = '<!--[if gt IE '+(++v)+']><i></i><![endif]-->',
div.getElementsByTagName('i')[0]
);
return v> 4 ? v : undef;
}());
Run Code Online (Sandbox Code Playgroud)
评论中还有其他有趣的解决方案.
测试功能,而不是浏览器.如果您使用并要求FormData,就像您在评论中所述,那么请将支票更改为:
if ( !("FormData" in window) ) {
// Tell the user to use a better browser, or whatever
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
32036 次 |
最近记录: |