peter
Guest
|
Simple prototype to give a string of characters random colors. Could be useful if someone is thinking of writing a UBBC script or something 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());
Last Edit: Nov 5, 2005 18:19:46 GMT by peter
|
|
|