![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
var Browser = {
isIE: (!navigator.userAgent.match(/Gecko/) && !window.opera),
isIE7: (navigator.userAgent.match(/MSIE\s+7/i)),
isIE8: (navigator.userAgent.match(/MSIE\s+8/i)),
isIE6: (!navigator.userAgent.match(/Gecko/) && !window.opera) && (!navigator.userAgent.match(/MSIE\s+7/i)) && (!navigator.userAgent.match(/MSIE\s+8/i)),
isSafari: (navigator.userAgent.match(/Safari/i)),
isChrome: (navigator.userAgent.toLowerCase().indexOf("chrome") > -1),
isMac: (navigator.platform.match(/mac/i)),
isOpera: !!window.opera,
isWindows: navigator.platform.match(/win[0-9]+/i)
};
lhgcore.J 的浏览器检测
(function(){
var axt = !!window.ActiveXObject,
b ={
ie: axt,
i7: axt && !!window.XMLHttpRequest,
i8: axt && !!document.querySelectorAll,
op: !!window.opera,
ff: !!window.Components,
sa: !!window.openDatabase
};
lhgcore.browser = b;
})();
var isIE = (document.all) ? true : false; if(isIE){alert("is ie")} else {alert("no ie");}/*
var is_IE = ( navigator.appName == "Microsoft Internet Explorer" );
var is_NN = ( navigator.appName == "Netscape" );
if(is_IE){
alert("This is IE!");
} else {
alert("This is no IE!");
}
*/
if (!/*@cc_on !@*/0) {
alert('no ie');
} else {
alert('ie');
}
if (!+"\v1") {
alert('ie');
} else {
alert('no ie');
}