Welcome to WebmasterWorld Guest from 54.147.199.169

Forum Moderators: open

Message Too Old, No Replies

Rotating JavaScript Image Suggestion

     
3:36 am on Mar 28, 2003 (gmt 0)

Junior Member from US 

10+ Year Member

joined:Jan 27, 2003
posts:127
votes: 0


I am looking for a JavaScript that will load a different image on a new page view. In other words, I would like to have a static image, that changes upon reloads. Does anyone know if this is possible without using cookies?

Any suggestions are much appreciated as well as URLS where I may find such code.

5:35 am on Mar 28, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:May 9, 2001
posts:416
votes: 0


A simple random generator can be used for image rotation:

<script language="JavaScript">
var rand_int = Math.floor(Math.random()*4);
var photos = new Array(4)
photos[0] = '<img src="image1.gif">';
photos[1] = '<img src="image2.gif">';
photos[2] = '<img src="image3.gif">';
photos[3] = '<img src="image4.gif">';
document.write(photos[rand_int]);
</script>

T