如何检测Internet Explorer 11及更低版本? [英] How to detect Internet Explorer 11 and below versions?
本文介绍了如何检测Internet Explorer 11及更低版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何检测我的网站用户是否使用带有Javascript的Internet Explorer 11或更低版本。
I'm wondering how I could detect if the user viewing my website is using Internet Explorer 11 or below versions with Javascript.
它应该是兼容的并适用于所有这些版本。
如何实现?
推荐答案
在这里,这应该适合你:
Here you go, this should work for you:
//Per Icycool, one liner
//function isIE(){
// return window.navigator.userAgent.match(/(MSIE|Trident)/);
// }
function isIE() {
var ua = window.navigator.userAgent; //Check the userAgent property of the window.navigator object
var msie = ua.indexOf('MSIE '); // IE 10 or older
var trident = ua.indexOf('Trident/'); //IE 11
return (msie > 0 || trident > 0);
}
//function to show alert if it's IE
function ShowIEAlert(){
if(isIE()){
alert("User is using IE");
}
}
这篇关于如何检测Internet Explorer 11及更低版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文