52、鼠标旋转效果

52、鼠标旋转效果

脚本说明:

把如下代码加入<body>区域中

<script language="JavaScript">

<!-- 

var speed;

var RunTime = 0;

var Xpos = 0;

var Ypos = 0;

var pulse=25;

var cnter=70;

var _y;

if (document.layers)

{

document.write('<LAYER NAME="a0" LEFT=10 TOP=10 BGCOLOR="#FF0000" CLIP="0,0,2,2"></LAYER>'

+'<LAYER NAME="a1" LEFT=10 TOP=10 BGCOLOR="#FF8000" CLIP="0,0,2,2"></LAYER>'

+'<LAYER NAME="a2" LEFT=10 TOP=10 BGCOLOR="#FFFF00" CLIP="0,0,2,2"></LAYER>'

+'<LAYER NAME="a3" LEFT=10 TOP=10 BGCOLOR="#00FF00" CLIP="0,0,2,2"></LAYER>'

+'<LAYER NAME="a4" LEFT=10 TOP=10 BGCOLOR="#0000FF" CLIP="0,0,2,2"></LAYER>'

+'<LAYER NAME="a5" LEFT=10 TOP=10 BGCOLOR="#FF00FF" CLIP="0,0,2,2"></LAYER>'

+'<LAYER NAME="a6" LEFT=10 TOP=10 BGCOLOR="#FFFFFF" CLIP="0,0,2,2"></LAYER>');

window.captureEvents(Event.MOUSEMOVE);

function xMoveHandler(evnt){

 Xpos = evnt.pageX;

 Ypos = evnt.pageY;

 }

 window.onMouseMove = xMoveHandler;

}

else if (document.all)

{

document.write('<div id="ieDiv" style="position:absolute;top:0px;left:0px">'

+'<div id="c" style="position:relative">'

+'<div style="position:absolute;top:0px;left:0px;width:2px;height:2px;background:#ff0000;font-size:2px"></div>'

+'<div style="position:absolute;top:0px;left:0px;width:2px;height:2px;background:#00ff00;font-size:2px"></div>'

+'<div style="position:absolute;top:0px;left:0px;width:2px;height:2px;background:#ffffff;font-size:2px"></div>'

+'<div style="position:absolute;top:0px;left:0px;width:2px;height:2px;background:#ffa500;font-size:2px"></div>'

+'<div style="position:absolute;top:0px;left:0px;width:2px;height:2px;background:#ff00ff;font-size:2px"></div>'

+'<div style="position:absolute;top:0px;left:0px;width:2px;height:2px;background:#8888ff;font-size:2px"></div>'

+'<div style="position:absolute;top:0px;left:0px;width:2px;height:2px;background:#fff000;font-size:2px"></div>'

+'</div>'

+'</div>');

function MoveHandler(){

Xpos = document.body.scrollLeft+event.x;

Ypos = document.body.scrollTop+event.y;

}

document.onmousemove = MoveHandler;

}

function sv3(){

if (RunTime<0.0550)

speed=0.001;

 

if (document.layers)

{

for (i=0;i<7;i++)

 {

var ntscp="a"+i

document.layers[ntscp].top=Ypos+cnter*Math.cos((RunTime+i*4.5)/5)*Math.sin((RunTime)*150);

document.layers[ntscp].left=Xpos+cnter*Math.sin((RunTime+i*4.5)/5)*Math.sin((RunTime)*150);

 }

}

else if (document.all)

{

for (i=0;i<ieDiv.all.c.all.length;i++)

 {

ieDiv.all.c.all[i].style.top=Ypos+cnter*Math.cos((RunTime+i*4.5)/5)*Math.sin((RunTime)*150);

ieDiv.all.c.all[i].style.left=Xpos+cnter*Math.sin((RunTime+i*4.5)/5)*Math.sin((RunTime)*150);

 }

}

RunTime+=speed;

stp=setTimeout('sv3()',10);

if (RunTime>0.0540)

{

speed+=0.002;

if (document.layers)

{

for (i=0;i<7;i++)

 {

var ntscp="a"+i

document.layers[ntscp].top=Ypos+cnter*Math.cos((RunTime+i*4.5)/5)

document.layers[ntscp].left=Xpos+cnter*Math.sin((RunTime+i*4.5)/5)

 }

}

else if (document.all)

{

for (i=0;i<ieDiv.all.c.all.length;i++)

 {

ieDiv.all.c.all[i].style.top=Ypos+cnter*Math.cos((RunTime+i*4.5)/5)

ieDiv.all.c.all[i].style.left=Xpos+cnter*Math.sin((RunTime+i*4.5)/5)

 }

}

}

if (speed > 0.5)

{

speed=0.5;

cnter-=8;

}

if (document.layers)

_y=-window.innerHeight;

else if (document.all)

_y=-document.body.clientHeight;

if (cnter <= _y)

{

RunTime=0;

speed=0.001;

cnter=70;

}

}

sv3();

//-->

</script>

 

Write a comment

Comments: 0