建站教学网,让你建站更便捷和轻松!
您当前的位置:首页 > 网页制作 > Javascript/Ajax

首页顶部弹出广告后自动关闭js代码

来源:建站教学网  时间:2011-03-16 22:47:36

<div id="slideAD" style="overflow: hidden; height:0; width:950PX; margin:0 auto;4">
<a href="http://www.jzread.com" target="_blank"><img src="http://www.jzread.com/skin/default/imga/bad.gif" width="950" height="300" border="0"/></a>
</div>
<!--全屏广告JS-->
<script type="text/javascript" language="javascript">
var intervalId = null;
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){
this.stayTime=nStayTime*1500 || 4500;
this.maxHeigth=nMaxHth || 300; //广告最大高度
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 +40 ) : (h - 40))+"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,2);
}
</script>
<script type="text/javascript">
slideAd('slideAD',5,"down",250);
</script>
<!--END全屏广告JS-->

责任编辑:admin

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
CopyRight 2008-2009, JZREAD.COM, Inc. All Rights Reserved
皖ICP备09015033号