zoukankan      html  css  js  c++  java
  • 首页头部下拉广告设计(javascript)

    加在Head中
    <script type="text/javascript" language="javascript">
    var intervalId = null;
    function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){
    this.stayTime=nStayTime*1000 || 3000;
    this.maxHeigth=nMaxHth || 330//广告最大高度
    this.minHeigth=nMinHth || 1;
    this.state=sState || "down" ;
    var obj = document.getElementById(id);
    if(intervalId != null)window.clearInterval(intervalId);
    function openBox(){
     
    var h = obj.offsetHeight;
     obj.style.height 
    = ((this.state == "down"? (h +5 ) : (h - 5))+"px";
     
    if(obj.offsetHeight>this.maxHeigth){
     window.clearInterval(intervalId);
     intervalId
    =window.setInterval(closeBox,this.stayTime);
     }

     
    if (obj.offsetHeight<this.minHeigth){
     window.clearInterval(intervalId);
     obj.style.display
    ="none";
     }

    }

    function closeBox(){
     slideAd(id,
    this.stayTime,"up",nMaxHth,nMinHth);
    }

    intervalId 
    = window.setInterval(openBox,2);
    }

    </script>

    加在Body下面
    <div id="slideAD" style="overflow: hidden; height: 0; padding-left:10px; 985px"><div id="hd"><img src="/img/close.gif" alt="关闭" onclick="slideAd('slideAD',5,'up');return false;"/></div>
    <div align="center">这里插入相应的图片或flash</script></div>
    </div>

    设置当页面完全加载之后执行,10MS 检测一次
    <script type="text/javascript">

      
    <!--   
      
    function   chk(){   
      (
    this.document.readyState=="complete")?slideAd('slideAD',8):setTimeout('chk()',10);   
      }
       
      chk();   
      
    //-->   


    </script>

  • 相关阅读:
    【redis】--安全
    【redis】-- 数据备份和恢复
    2018.2.8 cf
    寒假零碎的东西 不定时更新补充.......
    hdu 1018
    2018寒假acm训练计划
    UVAlive 7466
    母函数
    简单数学题(水的不能在水的题了)
    随便写写的搜索
  • 原文地址:https://www.cnblogs.com/kingboy/p/1042374.html
Copyright © 2011-2022 走看看