鼠标多次onmouseout时会加多个计时器,再onmouseout中加计时器前先清了计时器,但是并没什么用,是怎么回事?
<script type="text/javascript">
var area = document.getElementById("moocbox");
var con1 = document.getElementById("con1");
var con2 = document.getElementById("con2");
con2.innerHTML = con1.innerHTML;
var iLiHeight = 24;
var scroll = setInterval("scrollup()",50);
function scrollup(){
area.scrollTop++;
if(area.scrollTop % iLiHeight == 0){
clearInterval(scroll);
setTimeout("startmove()",2000);
}
if(area.scrollTop >= con1.offsetHeight){
area.scrollTop = 0;
}
}
function startmove(){
scroll = setInterval("scrollup()",50);
}
area.onmouseover = function(){
clearInterval(scroll);
}
area.onmouseout = function(){
clearInterval(scroll);//先清计时器
scroll = setInterval(scrollup,50);
}
</script>