Random Text Splitter
Rich Trowbridge Oct 4, 2001
Would you like to add some pizazz to your text? This script splits up a text string and makes each letter (or word) a random color and size. IE only.
The JavaScript Source: Miscellaneous: Random Text Splitter
Simply click inside the window below, use your cursor to highlight the script, and copy (type Control-c or Apple-c) the script into a new file in your text editor (such as Note Pad or Simple Text) and save (Control-s or Command-s). The script is yours!!!
<!-- TWO STEPS TO INSTALL RANDOM TEXT SPLITTER:
1. Copy the coding into the HEAD of your HTML document
2. Add the last code into the BODY of your HTML document -->
<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://www.javascriptsource.com -->
<!-- Rich Trowbridge -->
<!-- Begin
function randomise(){
var words=document.myform.wordlist.value;
var spacer="";
words=words.split(document.myform.randomiseby.options[document.myform.randomiseby.selectedIndex].value)
document.myform.code.value="";
var colourscheme=new Array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F")
for(var time=0;time<=(words.length-1);time++){
if(words[time]==" "){document.myform.code.value+=" "}
if(words[time]!=" "){
spacer=document.myform.randomiseby.options[document.myform.randomiseby.selectedIndex].value;
var c1=Math.round(Math.random()*(colourscheme.length-1));
var c2=Math.round(Math.random()*(colourscheme.length-1));
var c3=Math.round(Math.random()*(colourscheme.length-1));
var c4=Math.round(Math.random()*(colourscheme.length-1));
var c5=Math.round(Math.random()*(colourscheme.length-1));
var c6=Math.round(Math.random()*(colourscheme.length-1));
var size=1+Math.round(Math.random()*6);
document.myform.code.value+="<font color=\"#"+colourscheme[c1]+colourscheme[c2]+colourscheme[c3]+colourscheme[c4]+colourscheme[c5]+colourscheme[c6]+"\" size=\""+size+"\">"+words[time]+"</font>"+spacer+"";
}
}
looks_like.innerHTML=document.myform.code.value;
}
// End -->
</script>
</HEAD>
<!-- STEP TWO: Copy this code into the BODY of your HTML document -->
<BODY>
<div align="center">
<form name="myform" action="javascript:randomise()">
<input name="wordlist" value="The quick brown fox jumps over the lazy dog" size="50">
<br>
<select name="randomiseby">
<option value="">Randomize by letter</option>
<option value=" ">Randomize by word</option>
</select><br><br>
<input type="submit" value="Do it">
<br><br>
<span id="looks_like"></span>
<br><br>
<textarea name="code" rows="5" cols="50"></textarea>
</form>
</div>
<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: 2.45 KB --> Did you use this script? Do you like this site? Please link to us!
Leave a Response
(0 comments)