View Full Version : Featured Content Slider - Rotate 3 times and stop

03-30-2007, 05:14 AM
1) Script Title: Featured Content Slider

2) Script URL (on DD): http://dynamicdrive.com/dynamicindex17/featuredcontentslider.htm

3) Describe problem: The script works very well (thanks!), and was easy to integrate into my page. However, I don't like that it keeps going and going forever. I'd like it to automatically rotate, but I want it to go 3 times and then stop.

I could modify the script myself, but since you're more familiar with the script I though you folks might have a better, more efficient solution than what I would do. Would you send me any ideas you have with this?

In the future, it would be great if this were integrated into the script like this:

ContentSlider("slider1", 3000, linktextarray, "Foward")

NEW version examples slider rotates 3 times & stops:
ContentSlider("slider1", 3000, linktextarray, "Foward", 3)
ContentSlider("slider1", 3000|3, linktextarray, "Foward")
ContentSlider("slider1", 3000, , , 3)


Web Maestro Clay

03-31-2007, 10:59 AM
Sure, there are a few ways to do this, but my hacked up version would be to make the following changes to the .js file (or just download the modified .js file below). The changes to the original code are in red:

if (typeof autorun=="number" && autorun>0)
window[sliderid+"timer"]=setTimeout(function(){ContentSlider.autoturnpage(sliderid, autorun, cycles || 0)}, autorun)


ContentSlider.autoturnpage=function(sliderid, autorunperiod, cycles){
if (cycles>0){
var slider=document.getElementById(sliderid)
if (nextpagenumber==0)
slider.cyclecount=(typeof slider.cyclecount!="undefined")? slider.cyclecount+1 : 1
if (slider.cyclecount && slider.cyclecount==cycles)
window[sliderid+"timer"]=setTimeout(function(){ContentSlider.autoturnpage(sliderid, autorunperiod, cycles || 0)}, autorunperiod)

Then, to invoke a content slider that ends after 2 cycles, specify that using the last optional parameter:

ContentSlider("slider1", 1000, "", "", 2)

04-01-2007, 04:47 PM
Thanks I'll give it a shot!