??javascript>>現在很多網(wǎng)站廣告做的如火如荼,現在我就來(lái)介紹一下常見(jiàn)的對聯(lián)浮動(dòng)廣告效果的代碼使用方法,本文介紹的這種效果,在1024*768分辨率下正常顯示,在800*600的分辨率下可以自動(dòng)隱藏,以免遮住頁(yè)面影響訪(fǎng)問(wèn)者瀏覽內容,而且與前面兩個(gè)代碼不同的是,廣告圖下方增加了一個(gè)圖片按紐,允許訪(fǎng)客點(diǎn)擊關(guān)閉廣告圖片,下面文本框中就是實(shí)現效果所需代碼:vardelta=0。
??015;varcollection;varcloseB=false;functionfloaters(){this。items=[];this。addItem=function(id,x,y,content){document。write(''+content+'');varnewItem={};newItem。
??object=document。getElementById(id);newItem。x=x;newItem。y=y;this。items[this。items。length]=newItem;}this。play=function(){collection=this。
??itemssetInterval('play()',30);}}functionplay(){if(screen。width0?1:-1)*Math。ceil(Math。abs(dx));followObj。style。left=followObj。
??offsetLeft+dx;}if(followObj。offsetTop!=(document。body。scrollTop+followObj_y)){vardy=(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='';}}functioncloseBanner(){closeB=true;return;}vartheFloaters=newfloaters();//theFloaters。
??addItem('followDiv1','document。body。clientWidth-100',0,'
');theFloaters。addItem('followDiv2',0,0,'
');theFloaters。
??play();把上面的代碼另存為一個(gè)JS文件,然后在想實(shí)現此效果的頁(yè)面用調用即可,*代表你另存的文件名!注意修改廣告圖片地址和連接地址!。