<div class="codetitle"> <span><a style="CURSOR: pointer" data="9424" class="copybut" id="copybut9424" onclick="doCopy('code9424')"><u>复代码</u></a></span> 代码如下:</div> <div class="codebody" id="code9424"> <br><script type="text/javascript"> <br>var 공; <br>var mouseX = 100; <br>var mouseY = 100; <br>var 각도 = 0; <br>var 반경 = 0; <br><br>function draw(){ <br>ball = document.createElement("span"); <br>ball.style.position = "절대"; <br>ball.style.color = "#FF0000"; <br>ball.style.zIndex = 999999999; <br>ball.innerHTML = "●"; <br>document.body.appendChild(공); <br><br>ball.style["left"] = mouseX "px"; <br>ball.style["top"] = mouseY "px"; <br>} <br>function MousePos(e) <br>{ <br>e = e || 창.이벤트; <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>함수 setXY(e) <br>{ <br>e = e || 창.이벤트; <br>var pos = MousePos(e); <br>mouseX = pos.x; <br>mouseY = pos.y; <br>그리기(); <br>} <br>window.onload = function(){ <br>document.documentElement.onmousemove = function(e){ <br>e = e || 창.이벤트; <br>setXY(e); <br>}; <br>} <br></script> <br> </div> <br>效果演示代码:<br><div class="htmlarea"> <textarea id="runcode17710"> </textarea> <br><input onclick="runEx('runcode17710')" type="button" value="运行代码"><input onclick="doCopy('runcode17710')" type="button" value="复制代码"> <input onclick="doSave(runcode17710)" type="button" value="保存代码"> <a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">[Ctrl A 전체选注:</a>如需引入외부Js需刷新才能执行</div>]<br><a href="http://www.cnblogs.com/airy" target="_blank">출처:</a>http ://www.cnblogs.com/airy<script type="text/javascript"> var ball; var mouseX = 100; var mouseY = 100; var angle = 0; var radius = 0; function draw(){ ball = document.createElement("span"); ball.style.position = "absolute"; ball.style.color = "#FF0000"; ball.style.zIndex = 999999999; ball.innerHTML = "●"; document.body.appendChild(ball); ball.style["left"] = mouseX+ "px"; ball.style["top"] = mouseY+ "px"; } function MousePos(e) { e = e || window.event; var x,y; if(!document.all){ x = e.pageX; y = e.pageY; } else{ x = event.clientX + document.documentElement.scrollLeft; y = event.clientY + document.documentElement.scrollTop; } return {x:x,y:y}; } function setXY(e) { e = e || window.event; var pos = MousePos(e); mouseX = pos.x; mouseY = pos.y; draw(); } window.onload = function(){ document.documentElement.onmousemove = function(e){ e = e || window.event; setXY(e); }; } </script>