本帖最后由 rao3324180 于 2011-01-12 19:37:21 编辑

解决方案 »

  1.   

    onmouseover 中 clearInterval(time) 此处的time是全局的,
    如果 onmouseout = function(){setInterval("autoScroll2()",10)}
    那么,onmouseover 中 clearInterval(time)只是取消了 外面的 var time = setInterval("autoScroll2()",10); 之后 onmouseout 触发的定时器没办法消除,而且每次都会增加一个定时器,造成加快的效果。如果 onmouseout = function(){time = setInterval("autoScroll2()",10)}
    此时的time是指全局变量time,自然 clearInterval(time)就能消除该定时器如果 onmouseout = function(){var time = setInterval("autoScroll2()",10)}
    此时的time是指局部变量time,作用域只在此函数内,clearInterval(time)不能消除这个time引用的定时器.