/    Sign up×
Community /Pin to ProfileBookmark

Is there a function which can stop all processing in JS?

At some point in my program I want to stop running any JS functions or/and timeouts/timeintervals…
Can I stop processing probably untill user presses ‘reload’ button?
function or idea of code?

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisNov 09.2006 — clearTimeout()

clearInterval()

Nothing global.

I suppose you could use confirm() to force a reload.
<i>
</i>function die() {
if (confirm("I just can't go on any longer!"))
{window.history.go(0);}
else
{die();}
}
Copy linkTweet thisAlerts:
@gregaiziauthorNov 09.2006 — clearTimeout()

clearInterval()

Nothing global.

[/QUOTE]


To use clear functions I should know all intervals/timeouts. But what if I don't know and want to stop all of them once?

What do you mean 'nothing global'?

The function is interesting. Thanks
Copy linkTweet thisAlerts:
@gil_davisNov 09.2006 — To use clear functions I should know all intervals/timeouts.[/quote]
That is correct. If your intent is to stop a timer, then it should be equated to a var when it is started so you can use clearTimeout/Interval functions. If there are alot of separate timers, you could use an array to hold them and step through the array to stop them.
What do you mean 'nothing global'?[/quote]
Literally, there is nothing to stop any running timer. You have to stop each one specifically.
Copy linkTweet thisAlerts:
@mjdamatoNov 09.2006 — You could set a global variable, such as "runJS", and set it's value to true at the beginning of the page. Then make sure all functions have the first line:

if (runJS) {

You should be able to stop all functions from running by setting the value to false. It's a hack, but might work in your situation.
Copy linkTweet thisAlerts:
@gregaiziauthorNov 09.2006 — Thank you all guys.

I appreciate your help.
×

Success!

Help @gregaizi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...