/    Sign up×
Community /Pin to ProfileBookmark

pause a function

Is there a way to pause a function once inside it. Not uding the setTimeout(); function but once the function is called pause it for a half second or so. Example I want this function to pause for 1/2 second if the OS is Mac. Any thoughts?

Thanks for the reply

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@toicontienDec 04.2006 — You can use an alert box. But that's about it. Otherwise, you're stuck with setTimeout.
<i>
</i>var resumeFunc = function() {
pauseOnMacOS(true);
}

function pauseOnMacOS(skipPause) {
var myNum = 3;
if (!skipPause &amp;&amp; IS_MAC_OS) {
setTimeout(resumeFunc, 500);
} else {
alert(myNum);
}
}

I'm assuming the IS_MAC_OS variable is global and is set to true before the pauseOnMacOS() function is called.
Copy linkTweet thisAlerts:
@thechasboiauthorDec 04.2006 — toicontien

You are corect in the fact that the is mac is already set. I will try it your way. I will try and call a function similar to yours and then return true which allows the current function to continue. Thanks for the help. I did not think of doing it that way.. Thanks again.
×

Success!

Help @thechasboi 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...