Right, I'm currently trying to work out how to rotate a series of 5 images on a page in a random sequence. I've found this Javascript code to do it.
The problem is that I know nothing about Javascript (sort of figured I would try to become competent with HTML and CSS before learning anything else). Is there a way to do this using HTML? If not, how do you choose where on your page this Javascript code positions your picture? Or would you just place it inside a div like you would if you were putting one picture there?
<script language="Javascript">
<!--
var imlocation = "images/";
var currentdate = 0;
var image_number = 0;
function ImageArray (n) {
this.length = n;
for (var i =1; i <= n; i++) {
this = ' '
}
}
image = new ImageArray(3)
image[0] = 'image1.gif'
image[1] = 'image2.gif'
image[2] = 'image3.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>
The problem is that I know nothing about Javascript (sort of figured I would try to become competent with HTML and CSS before learning anything else). Is there a way to do this using HTML? If not, how do you choose where on your page this Javascript code positions your picture? Or would you just place it inside a div like you would if you were putting one picture there?