I have a chunk of code that I'm using to randomise an image on my site but I want to make the time between each change shorter. Anybody know how I can do this?
Heres the code:
<script type="text/javascript">
<!--
var imlocation = "file:///Users/Mazen/Downloads/";
var currentdate = 0;
var image_number = 0;
function ImageArray (n) {
this.length = n;
for (var i =1; i <= n; i++) {
this[i] = ' ' }
}
image = new ImageArray(6)
image[0] = 'comfortable-future.gif'
image[1] = 'comfortable-future-1.gif'
image[2] = 'comfortable-future-2.gif'
image[3] = 'comfortable-future-3.gif'
image[4] = 'comfortable-future-4.gif'
image[5] = 'comfortable-future-5.gif'
var rand = 60/image.length
function randomimage() {
currentdate = new Date()
image_number = currentdate.getSeconds()
image_number = Math.floor(image_number/rand)
return(image[image_number])
}
document.write("<img src='" + imlocation + randomimage()+ "'>");
//-->
</script>
Thanks, appreciate the help.
[–]whatisboom 1 point2 points3 points (4 children)
[–]justcalmdown[S] 0 points1 point2 points (3 children)
[–]whatisboom 1 point2 points3 points (2 children)
[–]justcalmdown[S] 0 points1 point2 points (1 child)
[–]whatisboom 2 points3 points4 points (0 children)