Rainbow Text

[Total: 0    Average: 0/5]

This shows how to have a sentence (or string) output with a variety of colors.

Body Code:

<script type=text/javascript>
var _a = "hi there. this is my rainbow sentence. look at my neat colors";
rainbow(_a);
function rainbow(_t) {
  var _s="";
  color = 0;
  var colorstep = Math.round(255 * 255 * 255 / _t.length);
  for (i=0; i < _t.length; i++) {
    color = (colorstep * i).toString(16);
	while (color.length < 6) color = "0"+color;
    document.write("<font color=#"+color+">"+_t.charAt(i)+"</font>");
	_s += color + " ** ";
  }
  //document.write("<BR>"+_s);
}
</script>

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *