View Single Post
  #7 (permalink)  
Old 01-28-2008, 07:11 PM
BigAlReturns's Avatar
BigAlReturns BigAlReturns is offline
Moderator Extraordinaire!
 
Join Date: Dec 2007
Location: The Wirral, England
Posts: 291
Send a message via MSN to BigAlReturns
Default

That works, but I think the code below is a more elegant way to achieve the same effect - obviously alter the amount added to num each time, and the timeout, to achieve what you want exactly.
Code:
<html>
<head>
<script type="text/javascript">
function timedText(num)
{
document.getElementById('displayDiv').innerHTML=num + ' milliseconds!';
num=num+1;
setTimeout('timedText('+num+')',1);
}
</script>
</head>
<body>
<form>
<input type="button" value="Display timed text!" onClick="timedText(0)">
<div id="displayDiv">
<p>Click on the button above. It will tell you when two, four, and six seconds have passed.</p>
</div>
</body>
</html>
Reply With Quote