发新话题
打印

[待解决] 到底如何加入:上下滚动的对联广告?

到底如何加入:上下滚动的对联广告?

同样的JS代码,在其他地方都可以上下滚动。

查论坛,按照很多提示做了改动,就是死活不滚动。。。。

有成功的同学没有,给点提示。。。。

TOP

复制内容到剪贴板
代码:
var delta=0.3;
var collection;
var closeB=false;
var isScrolling = false;//2005-4-13
function floaters() {
  this.items = [];
  this.addItem = function(id,x,y,content)
      {
     document.write('<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute;  width:65px; height:200px;left:'+(typeof(x)=='string'?eval(x):x)+';top:'+(typeof(y)=='string'?eval(y):y)+'">'+content+'</DIV>');
     
     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;
     var scrollTimeout;
     document.body.onscroll = function(){
      isScrolling = true;
      clearTimeout(scrollTimeout);
      scrollTimeout = setTimeout(function(){
       isScrolling = false;
      },200);
     }
     setInterval('play()',30);
      }
  }
  function play()
  {
   if(isScrolling==true){//在拖动时不执行
    return;
   }
   if(screen.width<=800 || closeB)
   {
    for(var i=0;i<collection.length;i++)
    {
     collection[i].object.style.display = 'none';
    }
    return;
   }
   for(var i=0;i<collection.length;i++)
   {
    var followObj  = collection[i].object;
    var followObj_x  = (typeof(collection[i].x)=='string'?eval(collection[i].x):collection[i].x);
    var followObj_y  = (typeof(collection[i].y)=='string'?eval(collection[i].y):collection[i].y);
    if(followObj.offsetLeft!=(document.body.scrollLeft+followObj_x)) {
     var dx=(document.body.scrollLeft+followObj_x-followObj.offsetLeft)*delta;
     dx=(dx>0?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 = '';
   }
  }

  
var theFloaters  = new floaters();
theFloaters.addItem('followDiv2','document.body.clientWidth-65',200,'<a target=blank href=http://网址><img src=themes/children/images/right.gif width=65 height=200 border=0></a>');

theFloaters.addItem('followDiv1',0,200,'<a onClick=\"window_custsearch();\" style=\"cursor:hand;\"><img src=themes/children/images/left.gif width=65 height=200 border=0 ></a>');

theFloaters.play();
上述文件是对联广告的代码。。

TOP

官方帮忙试试?就用默认模板。。。。。
加了{literal}{/literal}没有用

写成JS,然后调用也没有用

就是不滚动。。。。

[ 本帖最后由 xiaoxigua 于 2007-8-20 14:54 编辑 ]

TOP

有人帮看看不?

TOP

你自己能不能做一个演示出来给大家看呢!

TOP

我的解决咯

TOP

滚动得可以参考做浮动QQ的方式来弄吧!这个具体我也说不好了!
小店

TOP

发新话题