Need to have images randomize on my website, anyone know how

SnowPunk98

Banned
Jun 15, 2001
4,933
0
0
Basically I want banners to change every time the page is accessed so its even, anyone know how to do this with like a javascript or something
 

neomits

Diamond Member
Aug 18, 2001
3,228
0
76
Aww Dude my friend was just asking about this last week, cept his was to randomize the background picture. He figured it out but he's not online right now.... if you don't find an answer by the morning I should have one for you


BTW I don't know if you'll be able to see it in their code or not but the guys over at Penny Arcade are doing what I think you want to do with their banners.
 

audiophan

Senior member
May 2, 2001
699
0
0
if you don't mind/can use perl/cgi scripts then go to your fav search engine google and type in cgi resources. there are a lot of excellent scripts out there that do what you need
 

gopunk

Lifer
Jul 7, 2001
29,239
2
0
i'm not sure how feasible this is with client side code... either the client would have to download all the banners, and the script work from there, or there would have to be some sort of push pop functionality, where the javascript sends a request every once in a while... that might require the banners to be in an iframe or something like that.
 

jpsj82

Senior member
Oct 30, 2000
958
0
0
i like this one better

<!-- in head -->
<script language="JavaScript">
<!-- Hide from old browsers
// Copyright © 1999 Doug Popeney
// Created by Doug Popeney (easyjava@easyjavascipt.com)
// JavaScript Made Easy!! - http://www.easyjavascript.com

var imagenumber = 4 ;
var randomnumber = Math.random() ;
var rand1 = Math.round( (imagenumber-1) * randomnumber) + 1;
images = new Array
images[1] = "image1.jpg"
images[2] = "image2.jpg"
images[3] = "image3.jpg"
images[4] = "image4.jpg"

var image = images[rand1]
// -- End Hiding Here -->
</script>



<!-- in body -->
<script language="JavaScript">
<!-- Hide this script from old browsers --
document.write('<IMG SRC="' + image + '">')
// -- End Hiding Here -->
</script>