The functions are as follows:
Copy Code code as follows:
function GCL (i) {
var f=parseint ((i%15)/5);
i=i%15%5;
Switch (f) {
Case 0:return "#" +CS2 (255-i*51) +CS2 (i*51) + "00";
Case 1:return "#00" +CS2 (255-i*51) +cs2 (i*51);
Case 2:return "#" +CS2 (i*51) + "+CS2" (255-i*51);
}
}
function CS2 (i) {
var s=i.tostring (16);
Return ("+s"). substr (s.length);
}
Using GCL, you can use an incremented number to return a gradient color from red to green to blue. The gradient effect is as follows, a total of 15 colors, cycle gradients:
For example, use this function to gradient the background color of a hyperlink:
Home <script language=jscript> <!--function GCL (i) {var f=parseint ((i%15)/5); i=i%15%5; Switch (f) {case 0:return "#" +CS2 (255-i*51) +CS2 (i*51) + "00"; Case 1:return "#00" +CS2 (255-i*51) +cs2 (i*51); Case 2:return "#" +CS2 (i*51) + "+CS2" (255-i*51); }} function CS2 (i) {var s=i.tostring (16); Return ("+s"). substr (s.length); var A=document.getelementbyid (' a ') var sd=0; var cancel=0; function Colorful () {A.STYLE.BACKGROUNDCOLOR=GCL (sd++); if (!cancel) settimeout (' Colorful () ', 50); }--> </Script>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]
This function can also be modified to produce more detailed color changes, interested friends can try.