Jump to content

slideshow stop button help


MDanz

Recommended Posts

here is the code for the javascript slideshow

function nextslide() {

	// Hide current slide
          object = document.getElementById('slide' + current); //e.g. slide1
          object.style.display = 'none';
              
          // Show next slide, if last, loop back to front
          if (current == last) { current = 1; }
          else { current++ }
          object = document.getElementById('slide' + current);
          object.style.display = 'block';
	  setTimeout(nextslide, 2500);


       }
   

 

how do i stop the slideshow onmouseover?

 

i tried

nextslide.stop();

... but it never worked.

Link to comment
Share on other sites

function nextslide() {	// Hide current slide          
object = document.getElementById('slide' + current); //e.g. slide1          
object.style.display = 'none';                        
// Show next slide, if last, loop back to front         
if (current == last) { current = 1; }          
else { current++ }          
object = document.getElementById('slide' + current);          
object.style.display = 'block';		 
var timeout = setTimeout(nextslide, 2500);
object.onmouseover = clearTimeout(timeout);
object.onmouseout = timeout;							       
}

Link to comment
Share on other sites

In Aykay solution, the object.onmouseout = timeout; (timeout is an integer returned by setTimeout). You can replace that line with

object.onmouseout = nextslide;

 

Or set a global variable called pause and when the mouse over set "pause" to true and when mouse out set it to false and call the next slide. In your function, simply check the status of "pause"

Link to comment
Share on other sites

this is frustrating...

 

i changed the code to this to test.  Everytime it goes to the next slide the alert appears but i haven't clicked on anything????

function nextslide() {

                // Hide current slide
          object = document.getElementById('slide' + current); //e.g. slide1
          object.style.display = 'none';
             
          // Show next slide, if last, loop back to front
          if (current == last) { current = 1; }
          else { current++ }
          object = document.getElementById('slide' + current);
          object.style.display = 'block';
          var next = setTimeout(nextslide, 2500);
	  object.onclick = alert("hello");
		object.onmouseout = next;
                                        
       }

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.