下面的代码,是从天滑落一张图片。10秒后收上去。
但我希望,收上去5秒后又再次滑下。10秒后又再次收上去。5秒后再次滑下。如此反复。
请教高手,如何修改。谢谢。<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script type="text/javascript">
var intervalId = null;
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){
this.stayTime=nStayTime*1000 || 3000;
this.maxHeigth=nMaxHth || 666;
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>
<div id="MyMoveAd" style="height:6px;overflow:hidden;text-align:center;">
<img src=1.jpg>
</div>
<script type="text/javascript">
<!--
slideAd('MyMoveAd',2);
-->
</script>
但我希望,收上去5秒后又再次滑下。10秒后又再次收上去。5秒后再次滑下。如此反复。
请教高手,如何修改。谢谢。<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script type="text/javascript">
var intervalId = null;
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){
this.stayTime=nStayTime*1000 || 3000;
this.maxHeigth=nMaxHth || 666;
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>
<div id="MyMoveAd" style="height:6px;overflow:hidden;text-align:center;">
<img src=1.jpg>
</div>
<script type="text/javascript">
<!--
slideAd('MyMoveAd',2);
-->
</script>
解决方案 »
- ExtJs 再次载入panel
- javascript如何屏蔽鼠标双击,或将双击变成单击?
- 请教json转换实体bean的问题
- 求一个页面特效:一个层永远在页面底部居中~!
- 百思不得其解,只有靠这里的弟兄们了!
- myFocus为何在ie6下有些滤镜显示是黑色的长方形条形
- 这段javascript是什么意思?
- confirm("message")
- 这是jsp里的一段,现在我想让用户点击input框后,自动清空,如何写onclick后边的代码?
- 巨难:下拉框按字母键选取相关拼音首字母的问题。
- 哪位高手能否帮我做一个图片集旋转显示的效果..有图示....万分感谢..
- 在父页上通过一个超连接打开“弹出子页”,子页不处理不能操作父页
var intervalId = null;
function slideAd(id,nStayTime,sState,nMaxHth,nMinHth){
this.stayTime=nStayTime*1000 || 3000;
this.maxHeigth=nMaxHth || 666;
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";
setTimeout(function() { //<<<<<<<<<<<<<<<<
obj.style.display="";
slideAd('MyMoveAd',2);
}, 5000);
}
}
function closeBox(){
slideAd(id,this.stayTime,"up",nMaxHth,nMinHth);
}
intervalId = window.setInterval(openBox,10);
}
</script>
<div id="MyMoveAd" style="height:6px;overflow:hidden;text-align:center;">
<img src="http://zi.csdn.net/30060gn.gif">
</div>
<script type="text/javascript">
<!--
slideAd('MyMoveAd',2);
-->
</script>