现在很多网站广告做的如火如荼现在我就来介绍一下常见的对联浮动广告效果的代码使用方法本文介绍的这种效果在*分辨率下正常显示在*的分辨率下可以自动隐藏以免遮住页面影响访问者浏览内容下面文本框中就是实现效果所需代码 var delta= var collection; function floaters() { ems= []; thisaddItem= function(idxycontent) { documentwrite(<DIV id=+id+ >+content+</DIV>); var newItem= {}; newItemobject= documentgetElementById(id); newItemx= x; newItemy= y; ems[emslength]= newItem; } thisplay= function() { collection= ems setInterval(play()); } } function play() { if(screenwidth<=) { for(var i=;i<collectionlength;i++) { collection[i]objectstyledisplay= none; } return; } for(var i=;i<collectionlength;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(followObjoffsetLeft!=(documentbodyscrollLeft+followObj_x)) { var dx=(documentbodyscrollLeft+followObj_xfollowObjoffsetLeft)*delta; dx=(dx>?:)*Mathceil(Mathabs(dx)); followObjstyleleft=followObjoffsetLeft+dx; } if(followObjoffsetTop!=(documentbodyscrollTop+followObj_y)) { var dy=(documentbodyscrollTop+followObj_yfollowObjoffsetTop)*delta; dy=(dy>?:)*Mathceil(Mathabs(dy)); followObjstyletop=followObjoffsetTop+dy; } followObjstyledisplay= ; } } var theFloaters= new floaters(); theFloatersaddItem(followDivdocumentbodyclientWidth</a><br><a href=广告链接地址 target=_blank><img src=广告图片地址 width= height= border=></a>); theFloatersaddItem(followDiv<br><a href=广告链接地址 target=_blank><img src=广告图片地址 width= height= border=></a>); theFloatersplay(); 把上面的代码另存为一个JS文件然后在想实现此效果的页面用<script type=text/javascript language=javascript src=*js></SCRIPT>调用即可*代表你另存的文件名!注意修改广告图片地址和连接地址! |