[thelist] DIV visibility on Timer?

DESCHAMPS Stéphane DvSI/SICoR stephane.deschamps at francetelecom.com
Wed Jan 30 09:21:00 CST 2002


> Here's the simple (not!) effect I'm trying to create. You click on a
> button, triggering a slide show consisting of layers, which reveal
> themselves at set intervals of time. This could also be done if it had
> to with a swap image script as long as it could be timed. So for
> instance, when you clicked the button, Div1 (or gif1) would appear, 5
> seconds would pass, then Div2 would appear, 5 seconds, then Div3 etc.
>
> If anyone could help me with this I would be *really* grateful. And if
> it were x-browser I'd in heaven.

Let's say you've got a show/hide function already set.
Let's say they're called hide(divName), show(divName).

What I'd try would be :
- Create an array that sets the divs's time of visibility and order of
appearance :
<pseudo-code>
var divTimer = new Array();;
divTimer[0] = 5;
divTimer[1] = 7;
divTimer[2] = 3;
var divArray = new Array();
divArray[0] = myDiv1;
divArray[1] = myDiv2;
divArray[2] = myDiv3;
</pseudo-code>

- Create a function that hides previous and shows next and sets timeout to
re-run this function :
<pseudo-code>
function rollDivs(nDiv,timer) {
// you'd have to add a test to check if we're not at one end or the other of
the array, otherwise you'll add a few lines to manage this 'error'
hide(divArray[nDiv-1]);
show(divArray[nDiv]);
setTimeout ( rollDivs(nDiv+1) , divTimer(nDiv+1) );
}
</pseudo-code>

-

Sorry I can't write the code proper, I don't have my JS docs here...

Anyway, from that I think you can build something...

HTH
stef




More information about the thelist mailing list