rt谢谢

解决方案 »

  1.   


    <script type="text/javascript"> 
    var x1 = 10;
    var y1 = 300;
    var x2 = 410;
    var y2 = 300;
    var cx = Math.abs(x2-x1)/2;
    var cy = y1;
    var  r = Math.abs(x2-x1)/2;
    var obj, tid;
    var n = 0;
    function setit(){
       clearTimeout(tid);
       y = cy - r * Math.sin(n* (2 * Math.PI/360))
       x = cx - r * Math.cos(n* (2 * Math.PI/360))
    obj.style.left = x+5;
    obj.style.top = y+5;
       n += 5;
       if (n==360) n = 0;
       tid = setTimeout("setit()", 100);
    }window.onload=function(){
    obj = document.getElementById("pad");
    obj.style.left = x1;
    obj.style.top = y1;
       tid = setTimeout("setit()", 10);
    }
    </script> 
    </head> 
    <div id="pad" style="background:red;width:10px;height:10px;position:absolute;"></div>