Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2635
  • Last Modified:

pause function for slideshow that uses setInterval

Hi There,

I have a js slideshow that works when the page is loaded and then uses the setInterval function. What I would like to know is how can I pause and then resume with an onlick.

If anyone could post some samples that would be fantastic.

Sean - thanks in advance
0
MrAgile
Asked:
MrAgile
  • 2
1 Solution
 
lpxtechCommented:
Hi,

You can use clearInterval(interval) to stop and reset the interval to start again.
var pause;
var interval;
function start() {
  interval = setInterval('theFunction()',10000);
}
function pauseResume() {
  if(pause) {
    clearInterval(interval);
    pause = false;
  } else {
    interval = setInterval('theFunction()',10000);
    pause = true;
  }
}
start();

Open in new window

0
 
MrAgileAuthor Commented:
That's exactly what I needed. Thanks a lot.

Sean
0
 
lpxtechCommented:
No problem. Glad I could help. :-)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now