Artikel ini menjelaskan metode JS untuk mengimplementasikan blok warna rotasi saat mouse berkedip. Bagikan untuk referensi Anda. Metode implementasi spesifik adalah sebagai berikut:
Salin kode sebagai berikut: <Html>
<head>
<title> js mengikuti blok warna flash dari mouse </iteme>
</head>
<body>
<bahasa skrip = "javascript">
<!-
if (document.all) {
colors = new array ('ff0000', '00ff00', '3366ff', 'ff00ff', 'fffa500', 'ffffff', 'ffff000')
jumlah = colours.length;
YgetDelay = 0, xgetDelay = 0, ydelay = 0, xdelay = 0, langkah = 0.2, currstep = 0, my = 0, mx = 0;
document.write ('<div id = "ie" style = "Posisi: absolute; atas: 0; kiri: 0;"> <div style = "Posisi: relatif">');
untuk (i = 0; i <jumlah; i ++)
Document.write ('<div id = "iestars" style = "Posisi: Absolute; atas: 0px; kiri: 0px; tinggi: 50px; Lebar: 50px; font-family: kurir baru; ukuran font: 5px; warna:'+warna [i]+'; padding-top: 20px; Text-align: Center");
document.write ('</div> </div>');
ini = 1;
gStep = 1;
function iMouse () {
my = event.y; mx = event.x;
}
document.onmouseMove = iMouse
fungsi dim () {
ini- = gStep;
dt = setTimeout ('DIM ()', 10);
if (ini <2) {
ClearTimeout (DT);
binar();
}
}
fungsi glow () {
ini+= gStep;
gt = setTimeout ('glow ()', 10);
if (INI> 14) {
ClearTimeout (GT);
redup();
}
}
function stars () {
ie.style.top = document.body.scrolltop;
untuk (i = 0; i <jumlah; i ++)
{
var layer = iestars [i] .style;
Layer.filter = 'Glow (Color ='+Color [i]+', Strength ='+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 ((Currstep-5.99)/10))+i*70)*Math.sin ((Currstep)/10)*Math.cos ((Currstep+I*25)/10);
}
Currstep+= langkah;
}
function delay () {
Ydelay = ygetDelay+= (my-ygetdelay)*1/20;
XDelay = xgetDelay+= (mx-xgetDelay)*1/20;
bintang ();
setTimeout ('delay ()', 10);
}
menunda();
binar();
}
//->
</script>
</body>
</html>
Saya harap artikel ini akan membantu pemrograman JavaScript semua orang.