您的位置:首页 > 其它

判断是否IE6,如果是则提示升级浏览器

2013-03-09 11:58 302 查看
一个与浏览器有关的脚本 ,也是大家从事WEb前端编程常见的编程技巧,就是判断浏览器的版本,如果发现版本不符合你的设计要求,就给出提示升级浏览器,这样你的网页会更有体验。只有使用IE6浏览器才会看到效果。

<html>
<head>
<title>判断IE版本并给出提示升级浏览器</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<style type="text/CSS">
#ie6-warning{
rgb(255,255,225) url("") no-repeat scroll 3px;  < /span>
position:absolute;
top:0;
left:0;
font-size:50px;
color:#333;
width:100%;
height:500px;
padding: 2px 15px 2px 23px;
text-align:left;
line-height: 100px;
text-align: center;
z-index: 9999;
}
#ie6-warning a {
text-decoration:none;
color:green;
font-size: 40px;
}
</style>
<body>
<!--[if lte IE 6]>
<div id="ie6-warning">您正在使用 Internet Explorer 6,<br />在本页面的显示效果可能有差异。<br />建议您升级到 <a href="http://www.microsoft.com/china/windows/internet-explorer/" target="_blank">Internet Explorer 8</a> <br />或以下浏览器: <br /><a href="http://www.mozillaonline.com/">Firefox</a> / <a href="http://www.google.com/chrome/?hl=zh-CN">Chrome</a> / <a href="http://www.apple.com.cn/safari/">Safari</a> / <a href="http://www.operachina.com/">Opera</a>
</div>
<script type="text/javascript">
function position_fixed(el, eltop, elleft){
// check if this is IE6
if(!window.XMLHttpRequest)
window.onscroll = function(){
el.style.top = (document.documentElement.scrollTop + eltop)+"px";
el.style.left = (document.documentElement.scrollLeft + elleft)+"px";
}
else el.style.position = "fixed";
}
position_fixed(document.getElementById("ie6-warning"),0, 0);
</script>
<![endif]-->
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐