topical media & game development
graphic-javascript-effect-text-colorize-effect.htm / htm
<!-- TWO STEPS TO INSTALL COLORIZER:
1. Copy the coding into the HEAD of your HTML document
2. Add the onLoad event handler into the BODY tag -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<HEAD>
<!-- Original: Vjekoslav Begovic (vjbegovic@inet.hr ) -->
<!-- Web Site: -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
<script language="JavaScript1.2">
var msg = "JavaScript is nice!";
var colorTimer = null;
for (var i=0; i<msg.length; i++){
document.write("<span id = \"vjeko" + i + "\" style = \"color:blue; font-size:xx-large;\">" + msg.charAt(i) + "</span>");
}
function toHex(n){
var hexChars = "0123456789ABCDEF";
if (n == 0) return n;
var j, k;
var temp = "";
while (n != 0){
j = n % 16;
n = (n - j)/16;
temp = hexChars.charAt(j) + temp;
}
return temp;
}
function colorize(){
if (!document.all) return;
for (i=0; i<msg.length; i++){
k = Math.round(Math.random() * 16777215);
k = toHex(k);
while (k.length < 6){
k = k + "0";
}
document.all["vjeko" + i].style.color = '#' + k;
}
colorTimer = window.setTimeout("colorize()", 200);
}
</script>
// End -->
<!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->
<BODY onLoad="colorize()">
<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>
<!-- Script Size: 1.46 KB -->
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.