Text Erases Character At A Time

[Total: 0    Average: 0/5]

This shows how to have a string of text show up and then fade away character by character.

Body Code:

<script language="JavaScript1.2">
/*
If you want the text to appear differently on another place on the page
or anything set that in the style tag of the zoom layer. 

Here are the variables you have to set:                                                                 
First the text:
*/

	text="www.js-examples.com"

//set the fontsize you want:
	var fontsize=35

//The color of the text
	var color="#003300"
	
//the alignment of the text, you can choose center, right or left.
	var align="left"

//Set the speed you want it to write in (in milliseconds between each letter)
	var Wspeed=100

//Set font
	var font='Arial Black,Arial,Helvetica'
  
//Set the time you want it to wait before it starts after pageload:
	var timetowait=1000
        

document.write('<a href="#" onclick="writeInit()">Click to writetext</a>');


var ie, n;
if (document.all) {
	n=0; ie=1
	writeText='document.all.divZoom.innerHTML='<p align="'+align+'" style="font-family:'+font+'; font-size:'+fontsize+'px; color:'+color+'">'+text+'</p>''
	closeIt=""
}
if (document.layers) {
	n=1;ie=0
	writeText="document.divZoom.document.write('<p align="'+align+'" style="font-family:'+font+'; font-size:'+fontsize+'px; color:'+color+'">'+text+'</p>')"
	closeIt="document.divZoom.document.close()"
}

/*The functions for writing text.
****************************************************************************/
function writeIt(){
	if(text.length>0){
		text=text.slice(0,text.length-1)
		eval(writeText)
		eval(closeIt)
		setTimeout("writeIt()",Wspeed)
	}
}
/*This is the functions that calls the right function...or something :}
****************************************************************************/
function writeInit(){
	eval(writeText)
	eval(closeIt)
	if(ie || n) setTimeout("writeIt(0)",timetowait)       
}
//***************************************************************************
</script>
<div id="divZoom" style="position:absolute; top:1; left:1"></div>

Times Viewed: 0

Leave a Reply

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