Link to home
Start Free TrialLog in
Avatar of willa666
willa666Flag for United States of America

asked on

alternate between 3+ urls every 2 minutes

Hiya All

I have a need to have a page that shows a one of 3+ urls every 2 minutes.

I don't mind using iframe or having some javascript that manages the whole thing.

Ww
Avatar of TvMpt
TvMpt
Flag of Portugal image

Hi.
This code do what you want but needs a small changes

var d = new Date();
var t = d.getTime();
var days = Math.floor(t / (86400000));

2) put your images in an array

var imagearray = new Array('image1.jpg','image2.jpg'...);

3) use the MOD operator (%) to find the remainder when you divide days by the number of images in the array.

var i = days % imagearray.length;

4) then show the image corresponding to that value.

var img = new Image();
img.src = imagearray[i]; 

Open in new window


Just use an url array instead img's and instead 24h (86400000ms) use 3m ( 90000 )
ASKER CERTIFIED SOLUTION
Avatar of nap0leon
nap0leon

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial