Sunday, July 20, 2008

Timer in JavaScript

Syntax:

window.setTimeout(param1, param2, param3)

Parameters:
param1 Required; a function name or string of code that will execute when the timeout has elapsed.
param2 Required; the length of the timeout in milliseconds.
param3 Optional; param1's script language.
JScript,
vbscript,
vbs,
javascript,
XML.

Example:

< name="counter">< type="text" size="8" name="d2">< /form>

var seconds=5 ;
document.counter.d2.value='5' ;

function display(){
if (seconds>0){
seconds--;
setTimeout("display()",1000) ;
}
document.counter.d2.value=seconds;
}
display();


No comments:

search engine

Custom Search