大家好啊,我是菜鸟,下面这个代码是仿门户网站头部的伸缩广告
我想问下大家怎么修改能实现广告直接显示而不是慢慢的展开显示收起来的时候仍然保持慢慢的收缩还有这里面的几个参数是做什么用的呢slideAd(id,nStayTime,sState,nMaxHth,nMinHth)<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1
-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" lang="gb2312"> 
<head> 
<title> 滑动展开/收缩广告 </title> 
<meta http-equiv="content-type" content="text/html; charset=gb2312" /> 
<script type="text/javascript"> 
var intervalId = null; 
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){ 
  this.stayTime=nStayTime*1000 || 2000; 
  this.maxHeigth=nMaxHth ||400; 
  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 + 2) : (h - 2))+"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,10); 

</script> 
</head> 
<body style="margin:0;padding:0;font-size:14px;"> 
<div id="MyMoveAd" style="background:#ff0;height:0px;overflow:hidden;">
<image id="ADimg" src="http://desk.blueidea.com/DESK/XP/vista_2/vista_2019.jpg" style="height:300px;width:100%"> 
</div>
<script type="text/javascript"> 
function images_loading_bar(){
 if (document.getElementById("ADimg").complete)slideAd('MyMoveAd',2,'',280);
 else  setTimeout("images_loading_bar()", 64);
};
images_loading_bar();
</script> 
<div style="padding:20px">
<strong>滑动展开/收缩广告</strong><p>请刷新页面,再次观看演示效果 
</div>
</body> 
</html> 

解决方案 »

  1.   

    var intervalId = null; 
    function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){ 
      this.stayTime=nStayTime*1000 || 2000; 
      this.maxHeigth=nMaxHth ||400; 
      this.minHeigth=nMinHth || 1; 
      this.state=sState || "down" ;   var obj = document.getElementById(id);   if(intervalId != null)window.clearInterval(intervalId); if(this.state=='down'){obj.style.height=this.maxHeigth+'px';intervalId=window.setInterval(closeBox,this.stayTime); return false;}
      function openBox(){ 
      var h = obj.offsetHeight; 
      obj.style.height = ((this.state == "down") ? (h + 2) : (h - 2))+"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,10);