随即广告+漂浮广告

来源:互联网 发布:伙食补贴算法 编辑:程序博客网 时间:2024/04/26 12:06

<html>
<head>
<script language=javascript>
var x=50,y=60;
var xin =true,yin=true;
var step=1;
var delay=10;
function haha()
{
 var l=t=0;
 var r=document.body.offsetWidth-document.getElementById("Layer1").offsetWidth;
 var b=document.body.offsetHeight-document.getElementById("Layer1").offsetHeight;
 document.getElementById("Layer1").style.left=x;
 document.getElementById("Layer1").style.top=y;
 x=x+step*(xin?1:-1);
 if(x<l){xin=true;x=l;};
 if(x>r){xin=false;x=r;}
 y=y+step*(yin?1:-1);
 if(y<t){yin=true;y=t;};
 if(y>r){yin=false;y=b;}
 setTimeout("haha()",delay)
}
function ha()
{
    document.getElementById("Layer2").style.pixelTop=document.body.scrollTop+50;
}
window.onscroll=ha;
</script>
<style type="text/css">
<!--
#Layer2 {
 position:absolute;
 width:99px;
 height:187px;
 z-index:2;
 left: 16px;
 top: 158px;
 background-color: #FF0000;
}
-->
</style>
</head>

<body onLoad="haha()">
<p>fd</p>
<p>sf</p>
<div id="Layer1" style="position:absolute; width:84px; height:91px; z-index:1; left: 105px; top: 41px; background-color: #000000;"></div>
<p>dsfds</p>
<p>fs</p>
<p>sdf</p>
<p>sdf</p>
<div id="Layer2"></div>
<p>sdf</p>
<p>sdf</p>
<p>sdf</p>
<p>sdf</p>
<p>sd</p>
<p>fsd</p>
<p>f</p>
<p>sdf</p>
<p>sdf</p>
<p>sd</p>
<p>fs</p>
<p>df</p>
<p>dsf</p>
<p>sd</p>
<p>fsd</p>
<p>f</p>
<p>dsf</p>
<p>sd</p>
<p>f</p>
<p>sdf</p>
<p>sd</p>
<p>fsd</p>
<p>f</p>
<p>sd </p>
</body>
</html>