Home › Forums › Back End › PHP Slide Show Bug › Re: PHP Slide Show Bug
February 8, 2013 at 6:21 pm
#123840
Participant
First issue is a JavaScript issue. I think the `setInterval()` function calls build up when tabbed. You can try changing:
$(function() {
setInterval( “slideSwitch()”, 5000 );
});
into
$(function() {
var id = setInterval(slideSwitch, 5000);
$(window).blur(function(){
clearInterval(id);
});
$(window).focus(function(){
id = setInterval(slideSwitch, 5000);
});
});
to cancel the interval when the window loses focus and resume when it gains focus. (I haven’t tested this but it could work)