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

頁面兩側對聯廣告(鼠標感應)代碼效果

2022-06-13   來源: JSP教程 

  現在很多網站廣告做的如火如荼現在我就來介紹一下常見的對聯浮動廣告效果的代碼使用方法本文介紹的這種效果*分辨率下正常顯示*的分辨率下可以自動隱藏以免遮住頁面影響訪問者浏覽內容而且與前面一個代碼不同的是當鼠標移動到廣告圖片上是可以感應顯示另外設置好的廣告大圖效果下面文本框中就是實現效果所需代碼

function bigshow(){
documentalldiv_stylevisibility = visible;
documentalldiv_stylevisibility = hidden;
}
function bighide(){
documentalldiv_stylevisibility = visible;
documentalldiv_stylevisibility = hidden;
}

var ad_= new Array();
var ad_= new Array();
 ad_[]=<a href= target=_blank><img src=/img/js_gif border=></a>;
 ad_[]=<a href= target=_blank><img src=/img/js_gif border=></a>;
var imgheight;
var fubioleft;
windowscreenwidth> ? fubioleft=:fubioleft=
documentwrite(<DIV id=floater_left >);
ad_now = new Date();
ad_id= ad_nowgetSeconds() %
var adhead=<div id=div_ style=position:absolute; width:px; height:px; zindex: onMouseOver=bigshow();>;
var adhead=</div><div id=div_ style=position:absolute;  visibility: hidden; zindex:;width: ; height:   onMouseOut=bighide();>;
documentwrite(adhead+ad_[ad_id]+adhead+ad_[ad_id]+</div>);
documentwrite (</div>);
 selfonError=null;
 currentX = currentY =
     whichIt = null;          
     lastScrollX = ; lastScrollY = ;
     NS = (documentlayers) ? : ;
     IE = (documentall) ? : ;    
     function heartBeat() {
      if(IE) {
  diffY = documentbodyscrollTop;
  diffX = documentbodyscrollLeft; }
             if(NS) {
   diffY = selfpageYOffset; diffX = selfpageXOffset; }
      if(diffY != lastScrollY) {
                     percent = * (diffY lastScrollY);
                     if(percent > ) percent = Mathceil(percent);
                     else percent = Mathfloor(percent);
         if(IE) documentallfloater_leftstylepixelTop += percent;
         if(NS) documentfloater_lefttop += percent;
                     lastScrollY = lastScrollY + percent;
         }
      if(diffX != lastScrollX) {
       percent = * (diffX lastScrollX);
       if(percent > ) percent = Mathceil(percent);
       else percent = Mathfloor(percent);
       if(IE) documentallfloater_leftstylepixelLeft += percent;
       if(NS) documentfloater_leftleft += percent;
       lastScrollX = lastScrollX + percent;
      }
     }
 
     if(NS || IE) action = windowsetInterval(heartBeat());var ad_= new Array();
var ad_= new Array();
 ad_[]=<a href= target=_blank><img src=/img/js_gif border=></a>;
 ad_[]=<a href= target=_blank><img src=/img/js_gif border=></a>;
var imgheight;
var fubioleft;
windowscreenwidth> ? fubioleft=:fubioleft=
documentwrite(<DIV id=floater_right >);
ad_now = new Date();
ad_id= ad_nowgetSeconds() %

 function myload()
{
if (navigatorappName == Netscape)
{
documentdiv_right_pageX=+windowinnerWidth;
documentdiv_right_pageX=+windowinnerWidth;
mymove();
}
else
{
div_right_styleleft=documentbodyoffsetWidth;
div_right_styleleft=documentbodyoffsetWidth;
mymove();
}
}
function mymove()
 {
 if(documentns)
 {
 documentdiv_right_left=pageXOffset+windowinnerWidth;
 documentdiv_right_left=pageXOffset+windowinnerWidth;
 setTimeout(mymove();)
 }
 else
 {
div_right_styleleft=documentbodyscrollLeft+documentbodyoffsetWidth;
div_right_styleleft=documentbodyscrollLeft+documentbodyoffsetWidth;
setTimeout(mymove();)
 }
 }
 
var adhead=<div id=div_right_ style=position:absolute; width:px; height:px; zindex: onMouseOver=bigshow_right();>;
var adhead=</div><div id=div_right_  style=position:absolute;  visibility: hidden; zindex:;width: ; height: onMouseOut=bighide_right();><div align=right>;
documentwrite(adhead+ad_[ad_id]+adhead+ad_[ad_id]+</div></div>);
myload()
documentwrite (</div>);
 selfonError=null;
 currentX_right = currentY_right =
     whichIt_right = null;          
     lastScrollX_right = ; lastScrollY_right = ;
     NS = (documentlayers) ? : ;
     IE = (documentall) ? : ;    
     function heartBeat_right() {
      if(IE) {
  diffY_right = documentbodyscrollTop;
  diffX_right = documentbodyscrollLeft; }
             if(NS) {
   diffY_right = selfpageYOffset; diffX_right = selfpageXOffset; }
      if(diffY_right != lastScrollY_right) {
                     percent_right = * (diffY_right lastScrollY_right);
                     if(percent_right > ) percent_right = Mathceil(percent_right);
                     else percent_right = Mathfloor(percent_right);
         if(IE) documentallfloater_rightstylepixelTop += percent_right;
         if(NS) documentfloater_righttop += percent_right;
                     lastScrollY_right = lastScrollY_right + percent_right;
         }
      if(diffX_right != lastScrollX_right) {
       percent_right = * (diffX_right lastScrollX_right);
       if(percent_right > ) percent_right = Mathceil(percent_right);
       else percent_right = Mathfloor(percent_right);
       if(IE) documentallfloater_rightstylepixelLeft += percent_right;
       if(NS) documentfloater_rightleft += percent_right;
       lastScrollX_right = lastScrollX_right + percent_right;
      }
     }
 
     if(NS || IE) action = windowsetInterval(heartBeat_right());
function bigshow_right(){
documentalldiv_right_stylevisibility = visible;
documentalldiv_right_stylevisibility = hidden;
}
function bighide_right(){
documentalldiv_right_stylevisibility = visible;
documentalldiv_right_stylevisibility = hidden;
}documentwrite();
documentwrite();
documentwrite();

  把上面的代碼另存為一個JS文件然後在想實現此效果的頁面用<script type=text/javascript language=javascript src=*js></SCRIPT>調用即可*代表你另存的文件名!注意修改廣告圖片地址和連接地址!


From:http://tw.wingwit.com/Article/program/Java/JSP/201311/19165.html
  • 上一篇文章:

  • 下一篇文章:
  • 推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.