Click to See Complete Forum and Search --> : Replacing image with browser refresh


aprilneedshelp
01-24-2003, 01:46 PM
I used to have a small code snippet (I believe it was javascript) that allowed me to have a page pull up a different image each time the page was loaded. The images were kept in a specified folder and each time the page was refreshed or revisited a different photo would show up. I have searched for days and can't find anything anywhere!! Does anyone have this code or something similar?

I am looking because I have a small client who has photos of office staff and drivers from 3 offices that all need to be displayed but they are not worthy of their own page.

Help!


:confused:

Charles
01-24-2003, 02:17 PM
<script type="text/javascript">
<!--
images = ['http://www.bettiepage.com/images/photos/whip/whip11_a.jpg', 'http://www.bettiepage.com/images/photos/whip/whip5_a.jpg', 'http://www.bettiepage.com/images/photos/whip/whip7_a.jpg',
'http://www.bettiepage.com/images/photos/whip/whip10_a.jpg'];

altTexts = ['Bettie with a Whip', 'Bettie with a Whip', 'Bettie with a Whip', 'Bettie with a Whip'];

if (/number=(\d+)/.test(document.cookie)) {number = ++RegExp.$1} else {number = 1}
document.cookie = 'number=' + number % images.length;
document.write('<img src="', images[number-1], '" alt="', altTexts[number-1], '">');
// -->
</script>
<noscript><img alt="Bettie With a Whip" src="http://www.bettiepage.com/images/photos/whip/whip7_a.jpg"></noscript>

KeithP
01-24-2003, 10:06 PM
Here's a great simple banner rotator. I like this one.

http://javascript.internet.com/messages/banner-ads.html