固定层在浏览器的右下角

来源:互联网 发布:本赛季库里的数据 编辑:程序博客网 时间:2024/06/05 18:53

转自搜孤晶伟-搜狐博客

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>固定层在浏览器的右下角</title>
<head>
<style>
*{margin:0}
body{
 height:1000px;
 width:1000px;
 }
 #a{
 width:300px;
 height:100px;
 background:red;
 }
</style>
<script>
var isie6 = window.XMLHttpRequest?false:true;
window.onload = function(){
    var a = document.getElementById('a');
    var d = document.getElementById('d');
   if(isie6){
         a.style.position = 'absolute';
       
         window.onscroll = function(){
              d.innerHTML = '';
          }
   }else{
      a.style.position = 'fixed';
   }
      a.style.right = '0';
      a.style.bottom = '0';
}
</script>
</head>
<body>
<div id ="d" style="display:none;"></div>
<div id='a'>test</div>
</body>
</html>

原创粉丝点击