Hi. I am working on coding my website in CSS. I found this code script online to randomly show an image out of a few. For example, if you put 5 images into the script, it will randomize the image that shows up per visit.
This is the code:
If you look at this, I want to replace the picture of a bench with the random image. I suppose the best way to do this would be to take out the picture of the bench and leave that transparent, and embed the code beneath it.
How can I do it so that I can tell the code where to put the image? I want it to fit just as the bench picture is, so it will look exactly like it is now. (except the image that shown, will be random)
I don't want the Script to put the image way off to one side, obviously.
I hope this isnt confusing.
Any help appreciated!
Kevin
This is the code:
Code:
<script language="Javascript">
<!--
// please keep these lines on when you copy the source
// made by: Nicolas - http://www.javascript-page.com
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] = '0.gif'
image[1] = '1.gif'
image[2] = '2.gif'
image[3] = '3.gif'
image[4] = '4.gif'
image[5] = '5.gif'
image[6] = '6.gif'
image[7] = '7.gif'
image[8] = '8.gif'
image[9] = '9.gif'
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>
If you look at this, I want to replace the picture of a bench with the random image. I suppose the best way to do this would be to take out the picture of the bench and leave that transparent, and embed the code beneath it.
How can I do it so that I can tell the code where to put the image? I want it to fit just as the bench picture is, so it will look exactly like it is now. (except the image that shown, will be random)
I don't want the Script to put the image way off to one side, obviously.
I hope this isnt confusing.
Any help appreciated!
Kevin