Este artículo describe el método de JS para implementar los bloques de color de rotación a medida que el mouse parpadea. Compártelo para su referencia. El método de implementación específico es el siguiente:
Copie el código de la siguiente manera: <html>
<Evista>
<title> JS sigue el bloque de color intermitente del mouse </title>
</ablo>
<Body>
<script language = "javaScript">
<!-
if (document.all) {
Colors = New Array ('FF0000', '00ff00', '3366ff', 'ff00ff', 'fffa500', 'ffffff', 'fffff000')
cantidad = colores.length;
YgetDelay = 0, xgetDelay = 0, ydelay = 0, xdelay = 0, step = 0.2, currstep = 0, my = 0, mx = 0;
document.write ('<div id = "ie" style = "posición: absoluto; superior: 0; izquierda: 0;"> <div style = "posición: relativo">');
para (i = 0; i <cantidad; i ++)
document.write ('<div id = "iestars" style = "posición: absoluto; superior: 0px; izquierda: 0px; altura: 50px; ancho: 50px; font-family: Courier new; font-size: 5px; color:'+colores [i]+'; relleno-top: 20px; text-align: Center">. </div>');
document.write ('</div> </div>');
ini = 1;
gstep = 1;
función iMouse () {
my = event.y; mx = event.x;
}
document.onmousemove = iMouse
función dim () {
ini- = gstep;
dt = setTimeout ('dim ()', 10);
if (ini <2) {
ClearTimeOut (DT);
brillo();
}
}
function glow () {
ini+= gstep;
gt = setTimeOut ('GLOW ()', 10);
if (ini> 14) {
ClearTimeOut (GT);
oscuro();
}
}
function stars () {
ie.style.top = document.body.scrolltop;
para (i = 0; i <cantidad; i ++)
{
var layer = iStars [i] .style;
Layer.filter = 'Glow (color ='+Colors [i]+', fortaleza ='+ini+')';
Layer.top = ydelay+100*Math.sin ((5*Math.sin ((Currstep-5.99)/10))+I*70)*Math.sin ((Currstep)/10)*Math.Cos ((Currstep+I*25)/10);
Layer.left = XDELAY+180*MATH.COS ((5*MATH.SIN ((CURNSTEP-5.99)/10))+I*70)*MATH.SIN ((CURNSTEP)/10)*MATH.COS ((CURNSTEP+I*25)/10);
}
currstep+= step;
}
FUNCIÓN DELTER () {
Ydelay = ygetdelay+= (my-ygetdelay)*1/20;
Xdelay = xgetDelay+= (mx-xgetdelay)*1/20;
estrellas ();
setTimeOut ('demandado ()', 10);
}
demora();
brillo();
}
//->
</script>
</body>
</html>
Espero que este artículo sea útil para la programación de JavaScript de todos.