Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pausing the script executing 1

Status
Not open for further replies.

pankajv

Programmer
Jan 30, 2002
178
0
0
IN
Is there a way to pause the script execution for a specified interval of time.
 
no, but you can call a function at an interval:

function doThatEveryISeconds(iSeconds) {
window.setInterval("that();", iSeconds*1000);
}



=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
Here is an example of a ten second pause I used to prevent a form submission so that an associated function would work:

slowTime=window.setTimeout("document.Quiz.submit();document.Quiz.reset()",10000);
 
I have also tried this function, but it is of no use at the script execution continues and the function mentioned in the setTimeout method will wake up after the specified interval of time.

Thanks for the help.

Pankaj
 
pankajv,

you'll probably just have to break up your script into separate functions, and have them call each other with setTimeout or setInterval



=========================================================
try { succeed(); } catch(E) { tryAgain(); }
-jeff
 
I've tried this and it works, but how do I make it stop? it keeps calling the function over and over again.

Thanks,


________________________
JoelMac
 
attach a handle to the interval, and stop it by calling clearInterval(handle)

// start the interval
var myHandle = window.setInterval("foo();", 1000);

// stop it
window.clearInterval(myHandle);



=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top