0

In the original Javascript is there I want this to stop it

setTimeout('open_popup()',  200);

What is function To stop this from another file js

  • Do you mean you want to stop the setTimeout? – Soufiane Hassou Aug 31 '11 at 04:02
  • 1
    http://stackoverflow.com/questions/3141064/how-to-stop-all-timeouts-and-intervals-using-javascript is helpful – ssell Aug 31 '11 at 04:02
  • When you put a string in `setTimeout`, it will be `eval`ed. `setTimeout` expects a function as a first parameter, so you'll be fine just using `setTimeout(open_popup, 200)`. – Zirak Aug 31 '11 at 04:05

1 Answers1

3

setTimeout returns a handle that you can use the clear the timeout:

var timer = setTimeout(open_popup,  200);

clearTimeout(timer);

That of course assumes you put the timer variable in a scope that is accessible to both scripts and that you clear the timeout before it fires.

deceze
  • 510,633
  • 85
  • 743
  • 889
  • 2
    Also note that he passed the actual function to `setTimeout()`, and not a string to be `eval()`d. Using `eval()` (or any other function that internally `eval()`s code) is usually considered a bad practice. See http://stackoverflow.com/questions/86513/why-is-using-javascript-eval-function-a-bad-idea – shesek Aug 31 '11 at 04:03
  • not work this code plz see this code i wont to stop – manshyz Aug 31 '11 at 13:00