faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

8 of 15 people (53%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How do I Stop a page from completling an action, (e.g. stop setTimeout from closing the window)?

Apr 5th, 2008 19:58
ha mo, Colin Fraser, Kevin Smith,


The simplest way out would be not to use a setTimeOut(). However, what
you may also do is to try something like this:
Use a boolean variable and another variable to control the timer :
    ...
    var startTimer = false;  //the boolean variable
    var countDown = null;     //the name of the timer itself
function stopCountDown() {    //To turn the timeout off
    if (startTimer) {
        clearTimeOut(countDown) 
function setFlag() {         //the call to turn the timer off
      if (user-condition) {   //herein lies the real problem
          stopCountDown();
          startTimer = false;
      }   
}
function startCountDown()  {
       countDown = setTimeOut('setFlag()', 5000);
The problem with this of course is how can you dynamically determine
what conditions you want to turn the timer off? 
This may not be what you need but it may help you resolve some of the
issues you need to cover. Good luck.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com