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.


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I’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.


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thank you. Then I’ll use it.

Tobias.


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

You 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


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options