ActionsDev
3 replies to this thread. Most Recent
tobiaseichner
27 Feb 2010, 5:51 pm
JavaScript wait command ?
For a small JavaScript app I look for a way to interrupt code execution a few seconds till proceeding. For example:
...
document.forms[0].elements["result"].value = "Anything is okay. Proceeding";
return true;
Between these two commands the script should wait two seconds giving the user the chance to read the text.
I thought about adding a timeout, but maybe there is a more elegant solution (like “sleep” in Perl) ?
But even after having a close look at my reference books, I haven’t found something.
Tobias.
CGI/Perl scripts and software development - http://www.sunnyscript.com
Internet Consulting and Services - http://www.starenterprise.com
Joe Billings
27 Feb 2010, 6:32 pmI’m pretty sure timeout() is the equivalent of Perl’s sleep(). It’s a dedicated function built into the API so is likely be the most efficient solution.
Joe
On 27 Feb 2010, at 18:51, tobiaseichner wrote:
For a small JavaScript app I look for a way to interrupt code execution a few seconds till proceeding. For example:
... document.forms[0].elements["result"].value = "Anything is okay. Proceeding"; return true;Between these two commands the script should wait two seconds giving the user the chance to read the text.
I thought about adding a timeout, but maybe there is a more elegant solution (like “sleep” in Perl) ?
But even after having a close look at my reference books, I haven’t found something.
Tobias.
Joe Billings
Softpress Systems Ltd.
For free and responsive Freeway support, visit: http://www.softpress.com/kb/contact.php
For news, follow us on Twitter: http://twitter.com/softpress
Join us on Facebook: http://www.facebook.com/pages/Softpress/122661043517
tobiaseichner
27 Feb 2010, 7:22 pmThank you. Then I’ll use it.
Tobias.
CGI/Perl scripts and software development - http://www.sunnyscript.com
Internet Consulting and Services - http://www.starenterprise.com
waltd
27 Feb 2010, 11:46 pmYou have to set a variable to hold your function, or wrap the function in an anonymous function, then wrap the whole thing in setTimeout().
var foo = function(){
//Do something;
};
window.setTimeout(foo,100);
or
window.setTimeout(function(){
//hello world
},100);
Walter
Freeway user since 1997
