Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1177 How can I reveal a message a letter at a time?

You are here: irt.org | FAQ | DHTML | Q1177 [ previous next ]

Try:

<script language="JavaScript"><!--
function changeContent(what,text) {
    if (document.all)
        document.all[what].innerHTML = text;
    else if (document.layers) {
        document.layers[what].document.open();
        document.layers[what].document.write(text);
        document.layers[what].document.close();
    }
}

var text = "Hello world";
var i = 0;

function start() {
    changeContent('what',text.substring(0,++i))
    if (i<text.length)
        setTimeout('start()',500);
}
//--></script>

<body onLoad="start()">

<p>
<div id="what" style="position:absolute;"></div>
</p>

©2018 Martin Webb