<!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=gb2312" />
<title>js判断ie浏览器版本</title>
方法一
<script type='text/网页特效'>
var ie = !-[1,];
alert(ie);
</script>
方法二
<script type='text/javascript'>
notie = -[1,];
if(-[1,]){
// 标准浏览器代码
}else{
// ie only的代码
}
</script>
方法三
区分判定 ie 浏览器的代码,也可以参考下:
<script type='text/javascript'>
// option from dean edwards:
var ie = /*@cc_on!@*/false;
// use the commented line:
var ie//@cc_on=1;
// variation (shorter variable):
var ie = 'v'=='v';
//option to gareth hayes (former record-holder):
var ie = !+"v1";
</script>
方法四
<script language="javascript">
function getieversion()
{
if(navigator.appname == "microsoft internet explorer")
{
if(navigator.appversion.match(/7./i)=="7.")
{
alert( "当前浏览器是ie 7" )
}
if(navigator.appversion.match(/6./i)=="6.")
{
alert( "当前浏览器是ie 6" )
}
}
}
</script>
<input type="button" name="getieversion" value="获取当前浏览器版本" onclick="getieversion();" />
</head>
<body>
</body>
</html>