ASP动态网页设计与Ajax技术----漂浮广告


<html>
<head>
<meta charset="utf-8">
<title>漂浮广告</title>
</head>
<body>
<div id="Ad" style="position:absolute">
 < a href=" " target="_blank">
  < img src="照片/mmexport1567744347057.jpg" width="300" height="223" alt="" border="0"/></ a></div>\\注意照片位置需要自己调试;
<script>
 var x=50,y=60;
 var xin=true,yin=true;
 var step=1;
 var obj=document.getElementById("Ad");
 function floatAd(){
  var L=T=0;
  var R=document.body.clientWidth-obj.offsetWidth;
  var B=document.body.clientHeight-obj.offsetHeight;
  obj.style.left=x+document.body.scrollLeft;
  obj.style.top=y+document.body.scrollTop;
  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>B){yin=false;y=B;}
 }
 var itl=setInterval("floatAd()",10);
 obj.onmousemove=function(){clearInterval(itl);}
 obj.onmouseout=function(){itl=setInterval("floatAd()",10);}
 </script>
</body>
</html>

猜你喜欢

转载自www.cnblogs.com/sihuan/p/12091546.html