<!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" />
<meta name="keywords" content="代碼實例:滑動展開/收縮廣告" />
<script type="text/javascript">
var intervalId = null;
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){
stayTime=nStayTime*1000 || 3000;
maxHeigth=nMaxHth || 90;
minHeigth=nMinHth || 1;
state=sState || "down" ;
var obj = document.getElementById(id);
if(intervalId != null)window.clearInterval(intervalId);
function openBox(){
var h = obj.offsetHeight;
obj.style.height = ((state == "down") ? (h + 2) : (h - 2))+"px";
if(obj.offsetHeight>maxHeigth){
window.clearInterval(intervalId);
intervalId=window.setInterval(closeBox,stayTime);
}
if (obj.offsetHeight<minHeigth){
window.clearInterval(intervalId);
obj.style.display="none";
}
}
function closeBox(){
slideAd(id,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>這裡是廣告內內www.jzread.com</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>