熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Java編程 >> Javascript >> 正文

頁面兩側對聯廣告代碼效果

2013-11-11 21:10:04  來源: Javascript 

  現在很多網站廣告做的如火如荼現在我就來介紹一下常見的對聯浮動廣告效果的代碼使用方法本文介紹的這種效果*分辨率下正常顯示*的分辨率下可以自動隱藏以免遮住頁面影響訪問者浏覽內容下面文本框中就是實現效果所需代碼

  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>調用即可*代表你另存的文件名!注意修改廣告圖片地址和連接地址!


From:http://tw.wingwit.com/Article/program/Java/Javascript/201311/8552.html
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.