Return to Snippet

Revision: 26360
at April 25, 2010 13:21 by pablobablo


Initial Code
function teletype(id, text)
{
	function typechar( char )
	{
		if ( char == 'â—„' && document.getElementById(id).innerHTML >= 1)
		{
			document.getElementById(id).innerHTML = document.getElementById(id).innerHTML.substr(0, document.getElementById(id).innerHTML.length-1);
		}
		else
		{
			document.getElementById(id).innerHTML += char;
		}
	}
	
	var counter = 0;
	for( var i=0; i<text.length; i++ )
	{
		setTimeout(function()
		{
			var char = text[counter];
			typechar(char);
			counter++;
		},
		50 * i);
	}
}

Initial URL

                                

Initial Description

                                

Initial Title
Teletype Text in JavaScript

Initial Tags

                                

Initial Language
JavaScript