随页面滚动的对联广告 - 小众知识

随页面滚动的对联广告

2014-09-23 02:11:18 苏内容
  标签: 对联/滚动/广告
阅读:2957


随页面滚动的对联广告



随页面滚动的对联广告


JS代码如下:
<script language="JavaScript">
 var delta=0.8;
 var collection;
 var closeB=false;
 function floaters()
 {
 this.items= [];
 this.addItem= function(id,x,y,content)
 {    //向页面写入一个
document.write('
'); document.write(content+'
'); var newItem= {}; //获取元素属性 newItem.object= document.getElementById(id); newItem.x= x; //设置横坐标 newItem.y= y; //设置纵坐标 this.items[this.items.length]= newItem; } this.play= function() { collection= this.items; setInterval('play()',30); //调用函数play() } } function play() { if(screen.width<=800 || closeB) { for(var i=0;i0?1:-1)*Math.ceil(Math.abs(dx)); followObj.style.left=followObj.offsetLeft+dx; } //设置顶部位置 if(followObj.offsetTop!=(document.body.scrollTop+followObj_y)) { var dy=(document.body.scrollTop+followObj_y-followObj.offsetTop)*delta; dy=(dy>0?1:-1)*Math.ceil(Math.abs(dy)); followObj.style.top=followObj.offsetTop+dy; } followObj.style.display= ''; } } function closeBanner() //函数:关闭 { closeB=true; return; } var theFloaters= new floaters(); //添加广告图像 theFloaters.addItem('followDiv1','document.body.clientWidth-206',80,'广告内容二

'); theFloaters.addItem('followDiv2',6,80,'广告内容一

');///在这里改为文字或图片!!!! theFloaters.play(); //页面其他内容显示输出 for(var i=0;i<120;i++) { document.write("
这里是页面内容!
"); } </script>
扩展阅读
相关阅读
© CopyRight 2010-2021, PREDREAM.ORG, Inc.All Rights Reserved. 京ICP备13045924号-1