Definition and usage:
The setTimeout() method is used to call a function or calculated expression after a specified number of milliseconds.
grammar:
setTimeout(code,millisec)
parameter:
code (required): The JavaScript code string to be executed after the function to be called.
millisec (required): The number of milliseconds to wait before executing code.
hint:
setTimeout() only executes code once. If you want to call it multiple times, use setInterval() or have the code itself call setTimeout() again.
Example:
Copy the code code as follows:
<script language="javascript">
function timer(){
var value=Number(document.all['time'].value);
if (value>1) document.all['time'].value=value-1;
else {
document.all['time'].value="Agree";
return false;
}
window.setTimeout("timer()",1000);
}
</script>
<body onload="timer()">
<input name="time" value="10" type="button" />
</body>