为什么不会停止?
<style type="text/css">
#div1{ width:200px; height:200px; background-color:red; position: relative; left:-200px; top:0px;}
#div1 span{ display:block; width:20px; height:50px; background-color:blue; position:absolute; left:200px; top:75px;}
</style>
<script>
window.onload=function(){
var oDiv=document.getElementById("div1");
oDiv.onmouseover=function(){
starMove();
}
}
var timer=null;
function starMove()
{
clearInterval(timer);
var oDiv=document.getElementById('div1');
timer = setInterval(function()
{
if(oDiv.offsetLeft == 0)
{
window.clearInterval(timer);
}
else
{
oDiv.style.left = oDiv.offsetLeft+1+"px";
}
},30)
}