var all = [l1, l2, l3, l4, // l16 ],
randomnumber = Math.floor(Math.random() * all.length);
This function randomly selects a function to run (each function ajax-loads an image background).
How to ensure that you don't see the same image twice: that the function selected is eliminated subsequent runs. Maybe it can be done using 'pop', but I need a hand with the syntax… Any helpers?
pop is unsuitable because it can only remove the last element.
Originally Posted by ctoz
var all = [ l1, l2, l3, l4 ];
if( all.length )
all[ randomnumber = Math.floor( Math.random() * all.length ) ]();
all.splice( randomnumber, 1 );
Q: I found this code...
A: Then find its author.
You could use a session cookie to indicate which was the last one to load, then remove it from the array.
I think I'll go the splice way: not familiar with cookies.
I'd had a look at 'splice', but the way I was thinking about it, it looked too complicated.
—and if I get help I like to give credit.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread