MDanz Posted August 8, 2011 Share Posted August 8, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/244216-slideshow-stop-button-help/ Share on other sites More sharing options...
AyKay47 Posted August 8, 2011 Share Posted August 8, 2011 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; } Quote Link to comment https://forums.phpfreaks.com/topic/244216-slideshow-stop-button-help/#findComment-1254298 Share on other sites More sharing options...
MDanz Posted August 8, 2011 Author Share Posted August 8, 2011 thanks i tried that code and the slideshow stopped working? Quote Link to comment https://forums.phpfreaks.com/topic/244216-slideshow-stop-button-help/#findComment-1254326 Share on other sites More sharing options...
AyKay47 Posted August 8, 2011 Share Posted August 8, 2011 try adding another line declaring the timeout without storing it in a variable.. setTimeout(nextslide, 2500); Quote Link to comment https://forums.phpfreaks.com/topic/244216-slideshow-stop-button-help/#findComment-1254410 Share on other sites More sharing options...
nogray Posted August 8, 2011 Share Posted August 8, 2011 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" Quote Link to comment https://forums.phpfreaks.com/topic/244216-slideshow-stop-button-help/#findComment-1254450 Share on other sites More sharing options...
MDanz Posted August 10, 2011 Author Share Posted August 10, 2011 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; } Quote Link to comment https://forums.phpfreaks.com/topic/244216-slideshow-stop-button-help/#findComment-1255114 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.