日期:2014-05-16  浏览次数:20410 次

顶部展出的大幅广告的JS

 

 

<!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" >
<head>
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
    <title>顶部展出的大幅广告</title>
   <script type="text/javascript" language="javascript">
   (function(window){
       function _HY(id){
	     return document.getElementById(id);
	   }	   
	   function _Show(opt){  
		  if(opt.CurrentHeight<opt.Height){
		     opt.CurrentHeight=opt.CurrentHeight+opt.loadSpeed;		     
			 _HY(opt.eid).style.display = "";
             _HY(opt.eid).style.height = opt.CurrentHeight+"px";
			 
		     setTimeout(function(){
			   _Show(opt);
			 },50);
		  }else{
		    setTimeout(function(){
			   _Hide(opt);
			},opt.RetentionTime);
		  }
	   }
	   
	   function _Hide(opt){
	       if(opt.CurrentHeight>0){
		     opt.CurrentHeight=opt.CurrentHeight-opt.loadSpeed;			 
             _HY(opt.eid).style.height = opt.CurrentHeight+"px";			 
			 setTimeout(function(){
			   _Hide(opt);
			 },50);
		   }else{
		      _HY(opt.eid).style.display = "none";
		   }
	   }  
	   
	  var _TiggerAds=function(_eid,_Height,_loadSpeed,_RetentionTime){
	     var _opt={eid:_eid,Height:_Height,loadSpeed:_loadSpeed,RetentionTime:_RetentionTime,CurrentHeight:0};
		  _Show(_opt);
	  }	  
	  window.TiggerAds=_TiggerAds;
   })(window);

    
    window.onload = function()
    {
	    //参数说明:元素的ID,广告高度,显示隐藏的速度,显示后停留时间
	    TiggerAds('ads',600,60,7000);
   }
    </script>
    
    <script type="text/javascript" language="javascript">

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="ads" style="margin:auto; display:none; width:1002px; top:0px; height:0px; border:solid 1px #000; background-color:#fafafa; overflow:hidden; text-align:center;">
    </div>
    <div style="margin:auto; width:1002px; height:200px; border:solid 1px #000; background-color:#fafafa; text-align:center;">
        网站主体内容
    </div>
    </form>
</body>
</html>
<a href="http://blog.csdn.net/nnsword">魂宇工作室</a>