IE浏览器678版本判断
项目支持IE9以上,增加判断678给提示,这里记录几个方法:
<!DOCTYPE html> <html> <head> <meta charset='utf-8'> </head> <body> <script> //判断ie最简洁的代码 var ie = !-[1,]; alert(ie); /* ieTester ie6好使,ie78没用,但是用ie9的f12修改浏览器模式,78好使 //区分版本判断 function _ifIe () { var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串 var IE6 = IE7 = IE8 = false; var reIE = new RegExp("MSIE (\\d+\\.\\d+);"); reIE.test(userAgent); var fIEVersion = parseFloat(RegExp["$1"]); IE6 = fIEVersion == 6.0; IE7 = fIEVersion == 7.0; IE8 = fIEVersion == 8.0; if (IE6) { return "IE6"; } if (IE7) { return "IE7"; } if (IE8) { return "IE8"; } } if(_ifIe()) { alert('当前浏览器' + _ifIe() + '版本过低,请升级'); } */ /* ieTester ie6好使,ie78没用,但是用ie9的f12修改浏览器模式,78好使 var isIE=!!window.ActiveXObject; var isIE6=isIE&&!window.XMLHttpRequest; var isIE8=isIE&&!!document.documentMode; var isIE7=isIE&&!isIE6&&!isIE8; if (isIE){ if (isIE6){ alert("ie6"); }else if (isIE8){ alert("ie8"); }else if (isIE7){ alert("ie7"); } } */ var browser=navigator.appName var b_version=navigator.appVersion var version=b_version.split(";"); var trim_Version=version[1].replace(/[ ]/g,""); if(browser=="Microsoft Internet Explorer" && trim_Version=="MSIE6.0") { alert("IE 6.0"); } else if (browser=="Microsoft Internet Explorer" && trim_Version=="MSIE7.0") { alert("IE 7.0"); } else if (browser=="Microsoft Internet Explorer" && trim_Version=="MSIE8.0") { alert("IE 8.0"); } else if (browser=="Microsoft Internet Explorer" && trim_Version=="MSIE9.0") { alert("IE 9.0"); } </script> </body> </html>