|
Page Details >>>
A series of dots orbit the mouse cursor on the page, giving the appearance of a comet effect.
Add the below code to the <body> section of your page:
<div
id="starsDiv"
style="position:absolute;top:0px;left:0px">
<div
id="starsDiv0"
style="position:relative;width:1px;height:1px;background:#ffffff;font-size:1px;visibility:visible"></div>
<div
id="starsDiv1"
style="position:relative;width:1px;height:1px;background:#fff000;font-size:1px;visibility:visible"></div>
<div
id="starsDiv2"
style="position:relative;width:1px;height:1px;background:#ffa000;font-size:1px;visibility:visible"></div>
<div
id="starsDiv3"
style="position:relative;width:1px;height:1px;background:#ff00ff;font-size:1px;visibility:visible"></div>
<div
id="starsDiv4"
style="position:relative;width:1px;height:1px;background:#00ff00;font-size:1px;visibility:visible"></div>
<div
id="starsDiv5"
style="position:relative;width:1px;height:1px;background:#0000ff;font-size:1px;visibility:visible"></div>
<div
id="starsDiv6"
style="position:relative;width:1px;height:1px;background:#FF0000;font-size:1px;visibility:visible"></div>
<div
id="starsDiv7"
style="position:relative;width:2px;height:2px;background:#ffffff;font-size:2px;visibility:visible"></div>
<div
id="starsDiv8"
style="position:relative;width:2px;height:2px;background:#fff000;font-size:2px;visibility:visible"></div>
<div
id="starsDiv9"
style="position:relative;width:2px;height:2px;background:#ffa000;font-size:2px;visibility:visible"></div>
<div
id="starsDiv10"
style="position:relative;width:2px;height:2px;background:#ff00ff;font-size:2px;visibility:visible"></div>
<div
id="starsDiv11"
style="position:relative;width:2px;height:2px;background:#00ff00;font-size:2px;visibility:visible"></div>
<div
id="starsDiv12"
style="position:relative;width:2px;height:2px;background:#0000ff;font-size:2px;visibility:visible"></div>
<div
id="starsDiv13"
style="position:relative;width:3px;height:3px;background:#FF0000;font-size:3px;visibility:visible"></div>
</div>
<script
language="javascript"
type="text/javascript">
var
Clrs =
new
Array(6);
Clrs[0]
=
'ff0000';
Clrs[1]
=
'00ff00';
Clrs[2]
=
'000aff';
Clrs[3]
=
'ff00ff';
Clrs[4]
=
'fff000';
Clrs[5]
=
'fffff0';
var
yBase =
200;
var
xBase =
200;
var
step;
var
currStep =
0;
var
Xpos =
1;
var
Ypos =
1;
var
Xs =
200;
var
Ys =
400;
var
IE =
document.all?true:false;
if
(!IE)
document.captureEvents(Event.MOUSEMOVE)
document.onmousemove
=
getMouseXY;
var
tempX =
0;
var
tempY =
0;
function
getMouseXY(e)
{
if
(IE)
{
Xpos
=
event.clientX
+
document.body.scrollLeft;
Ypos
=
event.clientY
+
document.body.scrollTop;
}
else
{
Xpos
=
e.pageX;
Ypos
=
e.pageY;
}
if
(Xpos
<
0){Xpos
=
0;}
if
(Ypos
<
0){Ypos
=
0;}
return
true;
}
function
Comet()
{
if
(document.all)
{
yBase
=
window.document.body.offsetHeight
/
4;
xBase
=
window.document.body.offsetWidth
/
4;
}
else
{
yBase
=
window.innerHeight
/
4;
xBase
=
window.innerWidth
/
4;
}
for
(
i =
0
;
i <
14
;
i++
)
{
step
=
3;
var
Div =
eval("document.getElementById('starsDiv"+i+"')");
Div.style.top
=
Ypos +
yBase*Math.cos((currStep
+
i*4)/12)*Math.cos(0.7+currStep/200);
Div.style.left
=
Xpos +
xBase*Math.sin((currStep
+
i*3)/10)*Math.sin(8.2+currStep/400);
for
(ai
=
0;
ai <
Clrs.length;
ai++)
{
var
c=Math.round(Math.random()*[ai]);
}
Div.style.background
=
Clrs[c];
}
currStep
+=
step;
setTimeout("Comet()",
5);
}
Comet();
</script>
|
↓
|