回 帖 发 新 帖 刷新版面

主题:求对联广告一段

各位大虾,我现在在做也个800分辨率的页面,想要一段在网站两侧放广告图片的js代码(像对联一样一左一右),当拉动网页滚动条的时候对联广告也跟着向下调.
我在网上找了很多相关的代码来运行过,但要就是不行,要就是没那种效果,请大家手头上有相关的代码的就贴一贴吧,最后加点说明.在此先谢了!

回复列表 (共10个回复)

沙发

那是js代码,你可以在有那个广告的网页上找一下,将代码复制下来放到自己的页面上就可以用了

板凳

www.people.com.cn这个页面有个类似的80*80(深圳关爱行动)的,但我研究了很久都找不到他的代码,你能去看看吗?

3 楼

这里来一段换30分

里面的图片更具自己的需要作相应的改动
<SCRIPT language=JavaScript>
//左边
var left_img='<a href=# target=_blank><img src=images/1133251210074.gif border=0></a>';

//右边
var right_img='<br><a href=# target=_blank><img src=images/1133251210074.gif border=0></a>';
    var delta=0.05
    var collection;
    function floaters() {
        this.items    = [];
        this.addItem    = function(id,x,y,content)
                  {
                    document.write('<DIV id='+id+' style="Z-INDEX: 10; POSITION: absolute;  width:80px; height:60px;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
                    setInterval('play()',10);
                  }
        }
        function play()
        {

            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('followDiv1','document.body.clientWidth-120',230,''+right_img+'');
    theFloaters.addItem('followDiv2',0,230,''+left_img+'');
    theFloaters.play();
</SCRIPT>

4 楼

呵呵,我先试试再给你加分啦!

5 楼

呵呵,Web乐水,你给我的这段我已经有了,没能达到我说的那中效果.
var delta=0.015
   var collection;
   function floaters() {
       this.items    = [];
       this.addItem    = function(id,x,y,content)
                 {
                   document.write('<DIV id='+id+' style="Z-INDEX: 0; POSITION: absolute;  width:80px; height:60px;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
                   setInterval('play()',10);
                 }
       }
       function play()
       {
           if(screen.width<=800)
           {
               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('followDiv1','document.body.clientWidth-100',0,'</a><br><a href=广告链接地址 target=_blank><img src=广告图片地址 width=100 height=400 border=0></a>');
   theFloaters.addItem('followDiv2',0,0,'<br><a href=广告链接地址 target=_blank><img src=广告图片地址 width=100 height=400 border=0></a>');
   theFloaters.play();  

这个我的,效果跟你的一样,但不是我说的那种当拉动网页滚动条的时候也会向下移的那种

6 楼

你的30分我要定了

代码太多请到这里下载吧我刚放上去http://leshui.clwind.com/article.asp?id=50

如果你下载过去没有达到你要的效果我无话可说

7 楼

谢谢Web乐水,既然你这么热心,我不管能不能实现我要的功能,我也给你加了,呵呵!

8 楼

另外,我还有个问题想请教你们的.我想做一个非动态的页面,我用一个表格做了个页面,表格有两列,左边单元格是一些连接条目,右边单元格就是链接的内容,当我点击左边单元格的链接,相应的就会在右边的单元格上显示该链接的内容,请问这样的功能页面可以用JS来实现吗?

我还是新开个帖吧,你们有时间就去看看吧,谢谢了!

9 楼

谢谢Web乐水,给我的就是我想要的,谢谢你了!

10 楼

哈哈 美女人人得而助之
不用客气

我来回复

您尚未登录,请登录后再回复。点此登录或注册