首页 > Web开发 > 详细

JS如何判断IE和火狐与Chrome浏览器

时间:2014-09-17 20:08:22      阅读:195      评论:0      收藏:0      [点我收藏+]

JS如何判断IE和火狐与Chrome浏览器  

2013-08-16 21:01:17|  分类: 技术 |举报 |字号 订阅

 
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>

JS如何判断IE和火狐与Chrome浏览器

原文:http://www.cnblogs.com/dingyuanxin/p/3977775.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!