I need html code help
Posted: Thu 14 Apr, 2005 22.31
Can anyone give me the code where everytime the page is visited , or refreshed the banner image changes. Not everyday, but everytime it is visited. Thanks.
Code: Select all
<script language="JavaScript">
var piccies = new Array()
piccies[0] = 'picture1.jpg'
piccies[1] = 'picture2.jpg'
piccies[2] = 'picture3.jpg'
//If you want to have a greater number of pictures add additional items per line following the format above. Amend the filenames in inverted commas to those correct to the images you want to be available in your random selection.
The pictures can be called anything you want, not just picture1, picture2, etc.
var j = 0
var p = piccies.length;
var choosernd = new Array()
for (i = 0; i < p; i++){
choosernd[i] = new Image()
choosernd[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
document.write('<img src="'+piccies[whichImage]+'">');
</script>