Tuesday, 3 January 2012

Timeout

<html>
<head><title>Timeout Example</title>
<script>
var counter = 0;
ID=window.setTimeout("Update();",1000);

function Update(){
    counter++; // counter add itselves
    window.status="The counter is not at " + counter; // status bar show the message
    document.form1.input1.value="The counter is not at " + counter; //to show exact number on the text box
    ID=window.setTimeout("Update();", 1000); //
    }
</script>
</head>
<body>
<h1> Timeout Example</h1>
<hr />
<p>
the text value below and the status line are being updated every two seconds. Press the Reset button
to restart the count, or the stop button to stop it.
</p>

<hr />

<form name= "form1">
<input type = "text" name = "input1" size="40"> <br />
<input type = "button" value="reset" onClick="counter = 0;"> <br />
<input type = "button" value="stop" onClick =" window.clearTimeout(ID);">
<hr />
</body>
</html>

No comments:

Post a Comment