chenfahui'Blog

陈发辉的个人主页 chenfahui.cn

« 取得div的top值和left值textarea高度自适应 »

判断浏览器否为IE6

方法一:  

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>判断浏览器否为IE6</title>
</head>
 <body>
<input type="submit" onclick="ietester()" value="点击测试" />
<script type="text/javascript">
function ietester() {
var undef,
ie,
v = 3,
div = document.createElement('div'),
all = div.getElementsByTagName('i');
while (
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->',
all[0]
);
v > 4 ? ie=v : ie=undef;
 
if ( ie === 6 ) {
alert('IE6');
   } else {
alert('非ie6');
   }
}
</script>
</body>
</html>
  

 

 方法二:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="http://www.chenfahui.cn/ziliao/js/jquery-1.4.1.min.js"></script>
<title>判断浏览器否为IE6</title>
</head>
<body>
<script type="text/javascript">
function ietester2 (){
if($.browser.msie&&($.browser.version == "6.0")&&!$.support.style ){
alert("IE6")
}
else{
alert("非IE6")
}
};
</script>
<input value="点击测试" type="button" onclick="ietester2()" />
</body>
</html>

 

 

发表评论

网站分类

文章归档

Tags

Powered By Z-Blog 1.8 Walle Build 100427
Copyright 2009-2012 chenfahui.cn. Some Rights Reserved.www.chenfahui.cn网站PR查询