是否是Opera: is_opera = /opera/i.test(navigator.userAgent); alert(is_opera); [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行] 是否是IE: is_opera = /opera/i.test(navigator.userAgent); var is_ie = (/msie/i.test(navigator.userAgent) && !is_opera) alert(is_ie); [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行] 是否是ie7: 复制代码 代码如下: <BR>(is_ie && /msie 7\.0/i.test(navigator.userAgent)); <BR> var isIe = /msie/i.test(navigator.userAgent); alert(isIe); [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行] if(document.uniqueID){ alert("脚本在IE浏览器中运行!"); }else{ alert("脚本在非IE浏览器中运行!"); } [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行] javascript判断ie版本 function Browser() { var ua, s, i; this.isIE = false; // Internet Explorer this.isNS = false; // Netscape this.version = null; ua = navigator.userAgent; s = "MSIE"; if ((i = ua.indexOf(s)) >= 0) { this.isIE = true; this.version = parseFloat(ua.substr(i + s.length)); return; } s = "Netscape6/"; if ((i = ua.indexOf(s)) >= 0) { this.isNS = true; this.version = parseFloat(ua.substr(i + s.length)); return; } // Treat any other "Gecko" browser as NS 6.1. s = "Gecko"; if ((i = ua.indexOf(s)) >= 0) { this.isNS = true; this.version = 6.1; return; } } var browser = new Browser(); alert(browser); [Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]