Copy codeThe Code is as follows:
<Script type = "text/javascript">
Var ball;
Var mouseX = 100;
Varmousey = 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.doc umentElement. scrollLeft;
Y = event. clientY + document.doc umentElement. 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.doc umentElement. onmousemove = function (e ){
E = e | window. event;
SetXY (e );
};
}
</Script>
DEMO code:
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
Source: http://www.cnblogs.com/airy