Copy Code code as follows:
<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>
Effect Demo Code:
<textarea id="runcode13224"><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></textarea>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
Source: Http://www.cnblogs.com/airy