The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript random img on page load Re: random img on page load


I also agree that PHP is by far the best way to solve this problem. But supposing your host doesn’t provide PHP then you might want to try changing your randomImage function as follows:

function randomImage() {
var i = Math.floor(Math.random()*images.length);
document.getElementById(“random”).src=”Raw Images/” + images[i];