/    Sign up×
Community /Pin to ProfileBookmark

Stopping a funtion

I have this function makes a slideshow with divs:

[code]<script language=”JavaScript” type=”text/javascript”>

start_slideshow(1, 4, 10000);

function start_slideshow(start_frame, end_frame, delay) {
a = setTimeout(switch_slides(start_frame,start_frame,end_frame, delay), delay);
}

function switch_slides(frame, start_frame, end_frame, delay) {
return (function() {
Effect.Fade(‘slideshow’ + frame);
if (frame == end_frame) { frame = start_frame; } else { frame = frame + 1; }
b = setTimeout(“Effect.Appear(‘slideshow” + frame + “‘);”, 850);
c = setTimeout(switch_slides(frame, start_frame, end_frame, delay), delay + 850);
})
}

}[/code]

I need to be able to click a link to stop the slideshow.

I tried calling this function with a link:

[code]function clearstop() {
window.clearTimeout(a);
window.clearTimeout(b);
window.clearTimeout(c);[/code]

But if the slideshow hasn’t moved to the second div, then b and c are not defined so I get an error.

Please help ?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@jeffy777authorJan 07.2008 — nevermind, problem solved ?
×

Success!

Help @jeffy777 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,
)...