JS如何判断IE和火狐与Chrome浏览器
2013-08-16 21:01:17| 分类: 技术 |举报 |字号 订阅 javascript
var isIE=navigator.userAgent.toUpperCase().indexOf("MSIE")?true:false; 相似的能够写var isFirefox=navigator.userAgent.toUpperCase().indexOf("Firefox")?true:false; var isChrome = window.navigator.userAgent.indexOf("Chrome") !== -1 之类的东西大概就这样<script type="text/javascript">var isIE=navigator.userAgent.toUpperCase().indexOf("MSIE")==-1?false:true;if(isIE) document.getElementById("abc").style.display="";</script>实例 若是是IE显示DIV不然隐藏<body><div id=abc style="display:none;">11111111111</div><script type="text/javascript">var isIE=navigator.userAgent.toUpperCase().indexOf("MSIE")==-1?false:true;if(isIE) document.getElementById("abc").style.display="";</script></body>