<! Doctype HTML>
<HTML>
<Head>
<Meta charset = "UTF-8">
<Title> untitled document </title>
<SCRIPT>
Window. onload = function ()
{
VaR obtn = Document. getelementbyid ('btn ');
VaR obox = Document. getelementbyid ('box ');
VaR otex = Document. getelementbyid ('tex ');
Obtn. onclick = function ()
{
VaR value = otex. value;
If (! Value)
{
Alert ('Enter the content ');
Return;
};
VaR n = 0;
SetTimeout (F, RND (60,500 ));
Function f (){
N ++;
Obox. innerhtml = value. substring (0, n) + '<span >_</span> ';
If (n = value. length)
{
Obox. innerhtml = value. substring (0, N );
Alert ('callback ');
}
Else
{
SetTimeout (F, RND (60,500 ));
};
};
};
};
Function RND (n, m)
{
Return parseint (math. Random () * (m-n + 1) + n );
};
</SCRIPT>
</Head>
<Body>
<Input type = "button" value = "AA" id = "BTN">
<Textarea id = "Tex"> </textarea>
<Div id = "box" style = "width: 500px; Border: 1px solid #000; Height: 500px;"> </div>
</Body>
</Html>
Random typewriter time effect