Code
<!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>
<title> 代码实例:滑动展开/收缩广告 </title>
<meta name="author" content="李鹏飞,enetom.com">
<meta name="keywords" content="代码实例:滑动展开/收缩广告" />
<script type="text/javascript">
var intervalId = null;
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){
this.stayTime=nStayTime*1000 || 3000;
this.maxHeigth=nMaxHth || 90;
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:12px;overflow:hidden;">
<ul>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
</ul>
</div>
<p>代码实例:<strong>滑动展开/收缩广告</strong> 请刷新页面,再次观看演示效果</p>
<script type="text/javascript">
<!--
slideAd('MyMoveAd',2);
-->
</script>
</body>
</html> <center></center><a href='http://www.enetom.com' target=_blank>智博络特效</a>
<!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>
<title> 代码实例:滑动展开/收缩广告 </title>
<meta name="author" content="李鹏飞,enetom.com">
<meta name="keywords" content="代码实例:滑动展开/收缩广告" />
<script type="text/javascript">
var intervalId = null;
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){
this.stayTime=nStayTime*1000 || 3000;
this.maxHeigth=nMaxHth || 90;
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:12px;overflow:hidden;">
<ul>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
<li>这里是广告内内容</li>
</ul>
</div>
<p>代码实例:<strong>滑动展开/收缩广告</strong> 请刷新页面,再次观看演示效果</p>
<script type="text/javascript">
<!--
slideAd('MyMoveAd',2);
-->
</script>
</body>
</html> <center></center><a href='http://www.enetom.com' target=_blank>智博络特效</a>