How JavaScript implements the Rainbow text effect _javascript tips

Source: Internet
Author: User
Tags mul

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.