加在Head中
<
script type
=
"
text/javascript
"
language
=
"
javascript
"
>
var
intervalId
=
null
;
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
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);
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
function openBox()
{
var h = obj.offsetHeight;
obj.style.height = ((this.state == "down") ? (h +5 ) : (h - 5))+"px";
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
if(obj.offsetHeight>this.maxHeigth)
{
window.clearInterval(intervalId);
intervalId=window.setInterval(closeBox,this.stayTime);
}
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
if (obj.offsetHeight<this.minHeigth)
{
window.clearInterval(intervalId);
obj.style.display="none";
}
}
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
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; width: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
"
>
![](/Images/OutliningIndicators/None.gif)
<!--
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
function
chk()
{
(this.document.readyState=="complete")?slideAd('slideAD',8):setTimeout('chk()',10);
}
chk();
//
-->
![](/Images/OutliningIndicators/None.gif)
<
/
script>
转载于:https://www.cnblogs.com/kingboy/archive/2008/01/17/1042374.html