JavaScript实现IE6以下版本提示更新.

Navigator

获取浏览器的名称

var browser=navigator.appName

获取浏览器的版本

var b_version=navigator.appVersion  

进行对IE5.5 and IE6.0判断

if(b_version.indexOf("MSIE 6.0") != -1 || b_version.indexOf("MSIE 5.5") != -1){

如果条件成立,则对其执行:

document.getElementById("ie6").style.display = "block";

否则

alert("您目前使用的浏览器无需更新!")

整体代码:

<!DOCTYPE HTML>
<html>
<head>
<title> New Document </title>

<style type="text/css">
*
{margin:0;padding:0;}
ul
{list-style:none outside none;}
#ie6
{text-align:center;line-height:30px;display:none}
</style>


</head>

<body onload="detectBrowser()">
<script type="text/javascript">
function detectBrowser()
{
var browser=navigator.appName
var b_version=navigator.appVersion
if(b_version.indexOf("MSIE 6.0") != -1 || b_version.indexOf("MSIE 5.5") != -1){
document.getElementById(
"ie6").style.display = "block";
}
else{
alert(
"您目前使用的浏览器无需更新!")
}
}
//alert(navigator.appVersion)
//alert(navigator.appName)
</script>
<div id="ie6">
<h1>警告</h1>
<p>您目前使用的浏览器版本过于陈旧,请您立即更新你的浏览器!</p>
<p><a href="http://www.google.com/chrome/eula.html">Chrome</a> <a href="http://www.mozilla.com/en-US/firefox/new/">Firefox</a> <a href="http://www.opera.com/">Opera</a> <a href="http://www.apple.com.cn/safari/download/">Safari</a> <a href="http://info.msn.com.cn/ie9/">Internet Explorer 9</a></p>
</div>
</body>
</html>

posted @ 2011-04-10 17:26  深蓝色梦想  阅读(1876)  评论(0编辑  收藏  举报