Jump to content


Photo

breaking an setTimeout


  • Please log in to reply
2 replies to this topic

#1 Intelly XAD

Intelly XAD
  • Members
  • PipPip
  • Member
  • 14 posts
  • LocationNetherlands

Posted 18 October 2006 - 01:49 PM

Hi, I was wondering if there is a possibility to stop or break an setTimeout
For example, when you have:

setTimeout('hello()', 5000);

hello() wil be executed in 5 seconds, but I was wondering if ik could be stopped when an other command is executed

Many thnx in Advance
Experience does the trick...

An amateur is commonly better than someone who studied for it...

Don't mind my English, trust me, don't...

#2 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 18 October 2006 - 02:03 PM

yes. first you will need do declare a varaiable before you set the time out. Here is a simple example.

//our timer variable
var timer;

function startTimer() {
    timer = setTimeout('hello();', 5000);
}

function stopTimer() {
    clearInterval(timer);
}

Hope that helps,
Tom

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#3 Intelly XAD

Intelly XAD
  • Members
  • PipPip
  • Member
  • 14 posts
  • LocationNetherlands

Posted 18 October 2006 - 09:33 PM

Yes that helped very good, thnx :D
Experience does the trick...

An amateur is commonly better than someone who studied for it...

Don't mind my English, trust me, don't...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users