本文实例讲述了js实现跟随鼠标闪烁转动色块的方法。分享给大家供大家参考。具体实现方法如下:
复制代码 代码如下:
js跟随鼠标闪烁转动的色块
');
document.write('');
ini=1;
gstep=1;
function imouse(){
my=event.y;mx=event.x;
}
document.onmousemove=imouse
function dim(){
ini-=gstep;
dt=settimeout('dim()',10);
if (ini cleartimeout(dt);
glow();
}
}
function glow(){
ini+=gstep;
gt=settimeout('glow()',10);
if (ini > 14){
cleartimeout(gt);
dim();
}
}
function stars(){
ie.style.top=document.body.scrolltop;
for (i=0; i {
var layer=iestars[i].style;
layer.filter='glow(color='+colours[i]+', strength='+ini+')';
layer.top= ydelay+100*math.sin((5*math.sin((currstep-15.99)/10))+i*70)*math.sin((currstep)/10)*math.cos((currstep+i*25)/10);
layer.left=xdelay+180*math.cos((5*math.sin((currstep-15.99)/10))+i*70)*math.sin((currstep)/10)*math.cos((currstep+i*25)/10);
}
currstep+=step;
}
function delay(){
ydelay = ygetdelay+=(my-ygetdelay)*1/20;
xdelay = xgetdelay+=(mx-xgetdelay)*1/20;
stars();
settimeout('delay()',10);
}
delay();
glow();
}
//-->
希望本文所述对大家的javascript程序设计有所帮助。