下面这段代码是网友发的
谁能帮忙解释一下如何使用?
http://bbs.tydown.com/TopicOther.asp?t=5&BoardID=19&id=1684谢谢!!

解决方案 »

  1.   

    参考这个
    两边都有广告,左两个右两个var delta=0.15
    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-110',200,'<a href=http://www.15668.com/yp/rega.php?upuser=u_sykudown_n target=_blank><img src=http://www.syku.net/down/index/15668regyp.gif width=100 height=84 border=0></a><br><br><a href=http://union.kingsoft.com/union/download/index.html?uid=5673 target=_blank><img src=http://www.syku.net/down/index/king120120.GIF width=120 height=120 border=0></a><br>');
    theFloaters.addItem('followDiv2',10,200,'<a href=# target=_blank><img src=http://www.syku.net/down/index/100_100ad.gif width=100 height=100 border=0></a><br><br><a href=http://adfarm.mediaplex.com/ad/ck/4080-22903-9499-0?aid=syku;mini20_120x120;1yuan&mpro=http://pages.ebay.com.cn/im/landing/1yuan/1yuan.html target=_blank><img src=http://www.syku.net/down/index/mini20_120x120.gif border=0></a><br>');
    theFloaters.play();
      

  2.   

    第一步:将下面这段保存为:flr.js文件
    var imgheight
    document.ns = navigator.appName == "Netscape"
    window.screen.width>800 ? imgheight=100:imgheight=120
    function myload()
    {
    if (navigator.appName == "Netscape")
    {document.dangdang.pageY=pageYOffset+window.innerHeight-imgheight-0;
    document.dangdang.pageX=+window.innerWidth-107;
    mymove();
    }
    else
    {
    dangdang.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight-0;
    dangdang.style.left=document.body.offsetWidth-107;
    mymove();
    }
    }
    function mymove()
    {
    if(document.ns)
    {
    document.dangdang.top=pageYOffset+window.innerHeight-imgheight-0;
    document.dangdang.left=pageXOffset+window.innerWidth-107;
    setTimeout("mymove();",50)
    }
    else
    {
    dangdang.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight-0;
    dangdang.style.left=document.body.scrollLeft+document.body.offsetWidth-107;
    setTimeout("mymove();",50)
    }
    }function MM_reloadPage(init) { //reloads the window if Nav4 resized
    if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
    else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
    }
    MM_reloadPage(true)if (navigator.appName == "Netscape")
    {
    document.write("<layer id=dangdang top=300 width=80 height=80><a target=\'_blank\' 
    href=\'http://images.sohu.com/cs/minisite/shouxin07/index.htm\'><img border=\'0\' 
    src=\'../guanggao/8080.GIF\' width=\'80\' height=\'80\'></a></layer>");
    myload()}
    else
    {
    document.write("<div id=dangdang style=\'position: absolute;width:80;top:300;left:5;visibility:
    visible;z-index: 1\'><a target=\'_blank\' href=\'http://images.sohu.com/cs/minisite/
    shouxin07/index.htm\'><img border=\'0\' src=\'../guanggao/8080.GIF\' width=\'80\' height=\'80\'></a>
    </div>");
    myload()
    }
    第二步:将下面这段保存为:fll.js文件var imgheight
    var imgleft
    document.ns = navigator.appName == "Netscape"
    window.screen.width>800 ? imgheight=110:imgheight=110
    window.screen.width>800 ? imgleft=5:imgleft=5
    function myload()
    {
    if (navigator.appName == "Netscape")
    {document.myleft.pageY=pageYOffset+window.innerHeight-imgheight;
    document.myleft.pageX=imgleft;
    leftmove();
    }
    else
    {
    myleft.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight;
    myleft.style.left=imgleft;
    leftmove();
    }
    }
    function leftmove()
    {
    if(document.ns)
    {
    document.myleft.top=pageYOffset+window.innerHeight-imgheight
    document.myleft.left=imgleft;
    setTimeout("leftmove();",80)
    }
    else
    {
    myleft.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight;
    myleft.style.left=imgleft;
    setTimeout("leftmove();",80)
    }
    }function MM_reloadPage(init) { //reloads the window if Nav4 resized
    if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
    else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
    }
    MM_reloadPage(true)if (navigator.appName == "Netscape")
    {
    document.write("<layer id=myleft top=300 width=80 height=80><a target=\'_blank\' 
    href=\'http://www.polocars.com/\'><img border=\'0\' src=\'../guanggao/polosx-hp-mv.gif\' 
    width=\'80\' height=\'80\'></a></layer>");
    myload()}
    else
    {
    document.write("<div id=myleft style=\'position: absolute;width:80;top:300;left:5;visibility: 
    visible;z-index: 1\'><a target=\'_blank\' href=\'http://www.polocars.com/\'><img border=\'0\' 
    src=\'../guanggao/polosx-hp-mv.gif\' width=\'80\' height=\'80\'></a></div>");
    myload()
    }第三步:在要调用的页面的html代码中加入:
    <SCRIPT language="JavaScript" src="flr.js"></SCRIPT>
    <SCRIPT language="JavaScript" src="fll.js"></SCRIPT>注意:三个文件需要在同一目录下