订阅汇聚素材网Feed

IE6 IE7 IE8 IE9 IE浏览器版本JS判断

做网页常会用到JS检测IE的版本,下面是检测Explorer版本的三种代码!
第一种IE6 IE7 IE8 IE9 IE浏览器版本JS判断:

<script type=”text/javascript”>
var browser=navigator.appName
var b_version=navigator.appVersion
var version=b_version.split(“;”);
var trim_Version=version[1].replace(/[ ]/g,””);
if(browser==”Microsoft Internet Explorer” && trim_Version==”MSIE6.0″)
{
alert(“IE 6.0″);
}
else if(browser==”Microsoft Internet Explorer” && trim_Version==”MSIE7.0″)
{
alert(“IE 7.0″);
}
else if(browser==”Microsoft Internet Explorer” && trim_Version==”MSIE8.0″)
{
alert(“IE 8.0″);
}
else if(browser==”Microsoft Internet Explorer” && trim_Version==”MSIE9.0″)
{
alert(“IE 9.0″);
}
</script>

第二种IE6 IE7 IE8 IE9 IE浏览器版本JS判断:

<script type=”text/javascript”>
if(navigator.appName == “Microsoft Internet Explorer” && navigator.appVersion .split(“;”)[1].replace(/[ ]/g,””)==”MSIE6.0″)
{
alert(“IE 6.0″);
}
else if(navigator.appName == “Microsoft Internet Explorer” && navigator.appVersion .split(“;”)[1].replace(/[ ]/g,””)==”MSIE7.0″)
{
alert(“IE 7.0″);
}
else if(navigator.appName == “Microsoft Internet Explorer” && navigator.appVersion .split(“;”)[1].replace(/[ ]/g,””)==”MSIE8.0″)
{
alert(“IE 8.0″);
}
else if(navigator.appName == “Microsoft Internet Explorer” && navigator.appVersion .split(“;”)[1].replace(/[ ]/g,””)==”MSIE9.0″)
{
alert(“IE 9.0″);
}
</script>

第三种IE6 IE7 IE8 IE9 IE浏览器版本JS判断:

<script type=”text/javascript”>
if(navigator.appName == “Microsoft Internet Explorer” && navigator.appVersion.match(/7./i)==”7.”)
{
alert(“IE 7.0″);
}
else if(navigator.appName == “Microsoft Internet Explorer” && navigator.appVersion.match(/8./i)==”8.”)
{
alert(“IE 8.0″);
}
else if(navigator.appName == “Microsoft Internet Explorer” && navigator.appVersion.match(/9./i)==”9.”)
{
alert(“IE 9.0″);
}
else if(navigator.appName == “Microsoft Internet Explorer”)
{
alert(“IE 6.0″);
}
</script>

4 人Likes
  

文章转载请注明:IE6 IE7 IE8 IE9 IE浏览器版本JS判断-汇聚素材网

本文固定链接:http://www.webhj.com/hj-2043.html  +复制链接

IE6 IE7 IE8 IE9 IE浏览器版本JS判断:等您坐沙发呢!

发表评论

*

*

3 + 0

快捷键:Ctrl+Enter
0全站搜索 1 设计 2 素材 3 教材 4 WEB 5 电子书籍