Peter
New Member
God
Posts: 6
|
Post by Peter on Aug 24, 2005 15:30:26 GMT
Simple prototype to give a string of characters random colors. Could be useful if someone is thinking of writing a UBBC script, or whatever . <script type="text/javascript"> <!--
String.prototype.randCharColor = function(){ var temp = ""; for(c = 0; c < this.length; c ++){ r = Math.floor(Math.random() * 255); g = Math.floor(Math.random() * 255); b = Math.floor(Math.random() * 255); temp += '<span style="color: rgb(' + r + ', ' + g + ', ' + b + ')">' + this.charAt(c) + '</span>'; } return temp; }
var blah = "Test string to show random character color"; document.write(blah.randCharColor());
//--> </script>
|
|