This article illustrates the way JavaScript implements the Rainbow text effect. Share to everyone for your reference. as follows:
<HTML> <HEAD> <title>rainbow text</title> <script language= "JavaScript" > <!--Begin
Hide from old browsers function Createhexarray (n) {this.length = n;
for (var i = 1; I <= n; i++) this[i] = i-1;
THIS[11] = "A";
THIS[12] = "B";
THIS[13] = "C";
THIS[14] = "D";
THIS[15] = "E";
THIS[16] = "F";
return this;
} HX = new Createhexarray (16);
function Converttohex (x) {if (x <) x = 16;
var high = x/16;
var s = high+ "";
s = s.substring (0, 2);
High = parseint (S, 10);
var left = Hx[high + 1];
var low = X-high * 16;
if (Low < 1) low = 1;
s = low + "";
s = s.substring (0, 2);
Low = parseint (S, 10);
var right = Hx[low + 1];
var string = left + ' "+ right;
return string;
function Makerainbow (text) {text = text.substring (0, text.length);
COLOR_D1 = 255;
Mul = Color_d1/text.length;
for (var i = 0; i < text.length i++) {color_d1 = 255*math.sin (I/(TEXT.LENGTH/3));
COLOR_H1 = Converttohex (COLOR_D1); Color_D2 = Mul * i;
COLOR_H2 = Converttohex (COLOR_D2);
K = Text.length;
j = k-i;
if (J < 0) j = 0;
COLOR_D3 = Mul * J;
Color_h3 = Converttohex (COLOR_D3); document.write ("<font color=\" # "+ color_h3 + color_h1 + color_h2 +" \ ">" + text.substring (i, i + 1) + "</font
> "); }//End hide from old browsers--> </script> </HEAD> <body bgcolor= "#FFFFCC" > <center> <s trong> <font size=6> <script> <!--//change to your own text ... makerainbow ("Welcome to Boulder City N
Evada ");
document.write ("<br>");
Makerainbow ("The best dam city in the USA"); --> </script> </font> </strong> </center> </body>
The
wants this article to help you with your JavaScript programming.