View Full Version : setTimeout()??

04-15-2005, 03:11 AM
Any idea on how I might print to a page one letter at a time to make the appearence that it is coming from someone on a keyboard? I tried to put my text in an array and then using a for loop. In the for loop I used setTimeout and that was freakish.

04-15-2005, 04:56 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<p id="console">&gt; </p>

<script type="text/javascript">
var console = document.getElementById('console');
var text = "I'm typing this to you from outer space";
var i = 0;

function printText()
console.firstChild.nodeValue += text.charAt(i++);

if(i < text.length)
setTimeout(printText, 50);

setTimeout(printText, 50);

04-15-2005, 08:18 AM
You may want to look at this old text typer script of mine.