dcsimg

Lesson 43: The Script and Its Effect



The Script

<script language="JavaScript">

RightNow = new Date();

StartPoint = RightNow.getTime();
function StartTheCount()
{

var RightNow2 = new Date();
var CurrentTime = RightNow2.getTime();
var timeDifference = CurrentTime - StartPoint;
this.DifferenceInSeconds = timeDifference/1000;
return(this.DifferenceInSeconds);
}

function TheSeconds()
{
var SecCounts = StartTheCount();
var SecCounts1 = ""+SecCounts;
SecCounts1= SecCounts1.substring(0,SecCounts1.indexOf(".")) + " seconds";
if (DifferenceInSeconds >= 6)
{alert("done")}
else
{
document.FormCount.CountBox.value = SecCounts1
window.setTimeout('TheSeconds()',1000);}

}
</script>

<FORM NAME="FormCount">
<INPUT TYPE="text" size=9 NAME="CountBox">
</FORM>

The Script's Effect

Count to five then show an alert...

 

Back to the Index Page