代码如下: 复制代码 代码如下: <BR>var ball; <BR>var mouseX = 100; <BR>var mouseY = 100; <BR>var angle = 0; <BR>var radius = 50; <br><br>function run(){ <BR>if(ball === undefined){ <BR>ball = document.createElement("span"); <BR>ball.style.position = "absolute"; <BR>ball.style.color = "#FF0000"; <BR>ball.style.zIndex = 999999999; <BR>ball.innerHTML = "●"; <BR>document.body.appendChild(ball); <BR>} <br><br>ball.style["left"] = mouseX+(Math.cos(angle)*radius) + "px"; <BR>ball.style["top"] = mouseY+(Math.sin(angle)*radius) + "px"; <BR>angle+=0.1; <BR>} <BR>function MousePos(e) <BR>{ <BR>e = e || window.event; <BR>var x,y; <BR>if(!document.all){ <BR>x = e.pageX; <BR>y = e.pageY; <BR>} <BR>else{ <BR>x = event.clientX + document.documentElement.scrollLeft; <BR>y = event.clientY + document.documentElement.scrollTop; <BR>} <BR>return {x:x,y:y}; <BR>} <BR>function setXY(e) <BR>{ <BR>e = e || window.event; <BR>var pos = MousePos(e); <BR>mouseX = pos.x; <BR>mouseY = pos.y; <BR>} <BR>window.onload = function(){ <BR>setInterval(run,20); <br><br>document.documentElement.onmousemove = function(e){ <BR>e = e || window.event; <BR>setXY(e); <BR>}; <BR>} <BR> 作者: cnblogs airy