Jump to content

Archived

This topic is now archived and is closed to further replies.

Intelly XAD

breaking an setTimeout

Recommended Posts

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

Share this post


Link to post
Share on other sites
yes. first you will need do declare a varaiable before you set the time out. Here is a simple example.

[code=php:0]
//our timer variable
var timer;

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

function stopTimer() {
    clearInterval(timer);
}
[/code]

Hope that helps,
Tom

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.