...

View Full Version : setTimeout()??



johns311
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.

hemebond
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">
<head>
<title>57003</title>
</head>
<body>
<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);
</script>
</body>
</html>

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum