Pages

Sep 30, 2009

how to make javascript operation wait for some time without doing any process

Below is the function that halts the javascript process for specified number of milliseconds


function wait(msecs)
{
var start = new Date().getTime();

var cur = start

while(cur - start < msecs)

{

cur = new Date().getTime();

}

}


In Client side this can be called as wait(5000) will make the process wait for 5 seconds.
Note: you cannot execute anyother process at this time.

No comments: