kjs
05-24-2006, 01:01 AM
Hello all,
Ok so I've got this code to randomise the appearance of images on my site, but as the case stands, it doesn't actually do as I expected. Say I click refresh, all it does is go to the next image in the order in which I have listed them. Anyway, here's the code, and I was just wondering if any of you guys could help me to make it more spontaneous, and not just got from image 1 to image 2, then 3, then image 4 etc.
Thanks alot in advance everyone, here's the code:-
<script language="Javascript">
var currentdate = 0
var core = 0
function StringArray (n) {
this.length = n;
for (var i =1; i <= n; i++) {
this[i] = ' '
}
}
image = new StringArray(10)
image[0] = 'Images/CelebrityFish/anthonystewarthammerheadhea.jpg'
image[1] = 'Images/CelebrityFish/ashleeshrimpsonsimpson.jpg'
image[2] = 'Images/CelebrityFish/bananapirahnarama.jpg'
image[3] = 'Images/CelebrityFish/bennygillhill.jpg'
image[4] = 'Images/CelebrityFish/billgillmurray.jpg'
image[5] = 'Images/CelebrityFish/carlcarplewis.jpg'
image[6] = 'Images/CelebrityFish/cliffpilchardrichard.jpg'
image[7] = 'Images/CelebrityFish/davidgraylinggray.jpg'
image[8] = 'Images/CelebrityFish/dolphdolphinlundgren.jpg'
image[9] = 'Images/CelebrityFish/ericclamtunacantona.jpg'
var ran = 60/image.length
function ranimage() {
currentdate = new Date()
core = currentdate.getSeconds()
core = Math.floor(core/ran)
return(image[core])
}
document.write("<img src='" +ranimage()+ "'>")
</script>
Cheers, KJS.
Ok so I've got this code to randomise the appearance of images on my site, but as the case stands, it doesn't actually do as I expected. Say I click refresh, all it does is go to the next image in the order in which I have listed them. Anyway, here's the code, and I was just wondering if any of you guys could help me to make it more spontaneous, and not just got from image 1 to image 2, then 3, then image 4 etc.
Thanks alot in advance everyone, here's the code:-
<script language="Javascript">
var currentdate = 0
var core = 0
function StringArray (n) {
this.length = n;
for (var i =1; i <= n; i++) {
this[i] = ' '
}
}
image = new StringArray(10)
image[0] = 'Images/CelebrityFish/anthonystewarthammerheadhea.jpg'
image[1] = 'Images/CelebrityFish/ashleeshrimpsonsimpson.jpg'
image[2] = 'Images/CelebrityFish/bananapirahnarama.jpg'
image[3] = 'Images/CelebrityFish/bennygillhill.jpg'
image[4] = 'Images/CelebrityFish/billgillmurray.jpg'
image[5] = 'Images/CelebrityFish/carlcarplewis.jpg'
image[6] = 'Images/CelebrityFish/cliffpilchardrichard.jpg'
image[7] = 'Images/CelebrityFish/davidgraylinggray.jpg'
image[8] = 'Images/CelebrityFish/dolphdolphinlundgren.jpg'
image[9] = 'Images/CelebrityFish/ericclamtunacantona.jpg'
var ran = 60/image.length
function ranimage() {
currentdate = new Date()
core = currentdate.getSeconds()
core = Math.floor(core/ran)
return(image[core])
}
document.write("<img src='" +ranimage()+ "'>")
</script>
Cheers, KJS.