论坛首页 Web前端技术论坛

js判断浏览器是否IE8或者IE9

浏览 21212 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2012-12-25  
对于一些后台管理的企业应用,只要要求用户统一使用IE系列的浏览器就行了,目前之前都支持IE8和9

var IeMsg="请使用ie8或ie9浏览器";
var flag = true;
if(navigator.userAgent.indexOf("MSIE")>0)
{ 
	if(navigator.userAgent.indexOf("MSIE 6.0")>0)
	{ 
	flag = false;
	} 
	if(navigator.userAgent.indexOf("MSIE 7.0")>0)
	{
	flag = false;
	} 
	if(navigator.userAgent.indexOf("MSIE 8.0")>0)
	{
//	alert("ie8");
	} 
	if(navigator.userAgent.indexOf("MSIE 9.0")>0)
	{
	//alert("ie9");
	} 
}else
{
flag = false;
} 
if(!flag){
	document.getElementById("IEUse").innerHTML=IeMsg;
}


   发表时间:2012-12-25  
You can use jquery api more easier.

such as
   if($.browser.mozilla)
     alert("this is mozilla browser.");
0 请登录后投票
   发表时间:2012-12-25  
cectsky 写道
You can use jquery api more easier.

such as
   if($.browser.mozilla)
     alert("this is mozilla browser.");


话说我们的系统觉得没有必要支持JQERY,作为一个后台关系系统而非WEB网站,用JQUERY意义不大
而且,你只会用JQUERY而不理解javascript又有啥意义呢
0 请登录后投票
   发表时间:2012-12-25  
傲世凡尘 写道
cectsky 写道
You can use jquery api more easier.

such as
   if($.browser.mozilla)
     alert("this is mozilla browser.");


话说我们的系统觉得没有必要支持JQERY,作为一个后台关系系统而非WEB网站,用JQUERY意义不大
而且,你只会用JQUERY而不理解javascript又有啥意义呢


反方观点below
1 this's not js scope, but html dom
2 你仅仅是对MSIE做了判断,如果是others
3 有的时候 indexOf未必有效
4 谁说我会用jquery就不会js的
0 请登录后投票
   发表时间:2012-12-25  
cectsky 写道

反方观点below
1 this's not js scope, but html dom
2 你仅仅是对MSIE做了判断,如果是others
3 有的时候 indexOf未必有效
4 谁说我会用jquery就不会js的




第一点你说的是对的,确实是DOM模型的东西,
第二点我只希望我的应用可以在IE89上运行,所以无需判断他是FIREFOX还是CHRMOE
第三点indexof确实会有时候无效,但是在这里100%有效
第四点呵呵,我没说你不会JS阿,我只是说需要理解JS的原理。我的jquery写的一般,
但是还是会用的....

0 请登录后投票
   发表时间:2012-12-27  
用正则也可。
0 请登录后投票
   发表时间:2012-12-28  
傲世凡尘 写道
cectsky 写道
You can use jquery api more easier.

such as
   if($.browser.mozilla)
     alert("this is mozilla browser.");


话说我们的系统觉得没有必要支持JQERY,作为一个后台关系系统而非WEB网站,用JQUERY意义不大
而且,你只会用JQUERY而不理解javascript又有啥意义呢


你就这么确定 @cectksy 只会 jQuery ? (这不是一个好的讨论方式, 小心把楼引歪了。)

这也是一种方式:
		<!-- for IE6-8 support of HTML5 elements -->
		<!--[if lt IE 9]>
			<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
		<![endif]-->




0 请登录后投票
   发表时间:2012-12-28  
//by 司徒正美 http://www.cnblogs.com/rubylouvre/archive/2009/10/14/1583362.html
     ie = (function() {
          var v = 3, div = document.createElement('div'), a = div.all || [];
          while (div.innerHTML = '<!--[if gt IE '+(++v)+']><br><![endif]-->', a[0]);
          return v > 4 ? v : !v;
        }());

0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics