In diesem Artikel wird die Methode von JS beschrieben, um die Rotationsfarbenblöcke als Mausblitz zu implementieren. Teilen Sie es für Ihre Referenz. Die spezifische Implementierungsmethode lautet wie folgt:
Kopieren Sie den Code wie folgt: <html>
<kopf>
<titels> js folgt dem blinkenden Farbblock der Maus </title>
</head>
<body>
<script Language = "JavaScript">
<!-
if (document.all) {
Farben = Neuarray ('ff0000', '00ff00', '3366ff', 'ff00ff', 'fffa500', 'ffffff', 'ffff000')
Menge = colours.length;
YgetDelay = 0, xgetDelay = 0, ydelay = 0, xDelay = 0, Schritt = 0,2, Currstep = 0, my = 0, mx = 0;
document.write ('<div id = "ie" style = "Position: absolut; top: 0; links: 0;"> <div style = "Position: relative">');
für (i = 0; i <Menge; i ++)
document.write ('<div id = "iestars" style = "Position: absolut; top: 0px; links: 0px; Höhe: 50px; Breite: 50px; Schriftfamilie: Kurier neu; Schriftgröße: 5px; Farbe:'+Farben [i]+'; Padding-Top: 20px; Text-Align: Mitte">.
document.write ('</div> </div>');
Ini = 1;
gstep = 1;
Funktion imouse () {
my = event.y; mx = event.x;
}
document.onmousemove = Imouse
Funktion dim () {
ini- = gstep;
dt = setTimeout ('dim ()', 10);
if (ini <2) {
Clearimeout (DT);
glühen();
}
}
Funktion Glow () {
Ini+= gstep;
gt = setTimeout ('Glow ()', 10);
if (ini> 14) {
Clearimeout (GT);
Dim ();
}
}
Funktion stars () {
IE.Style.top = document.body.scrolltop;
für (i = 0; i <Menge; i ++)
{
var Layer = iestars [i] .style;
Layer.Filter = 'Glow (color ='+farben [i]+', Stärke ='+ini+')';
Layer.top = ydelay+100*math.sin ((5*math.sin ((Currstep-17,99)/10))+i*70)*Math.sin ((Currstep)/10)*Math.cos ((Currstep+i*25)/10);
Layer.left = xDelay+180*math.cos ((5*math.sin ((Currstep-17,99)/10))+i*70)*Math.sin ((Currstep)/10)*Math.cos ((Currstep+i*25)/10);
}
Currstep+= Schritt;
}
Funktion Delay () {
Ydelay = ygetDelay+= (my-yGetDelay)*1/20;
XDelay = xgetDelay+= (mx-xgetDelay)*1/20;
stars ();
setTimeout ('Delay ()', 10);
}
Verzögerung();
glühen();
}
//->
</script>
</body>
</html>
Ich hoffe, dieser Artikel wird für JavaScript -Programme aller hilfreich sein.