Forum Moderators: open
every time I reload the page it use a different pic but it's gonna use that pic as long as the page is loaded does it make sence?
any way ere is the code
Also I was getting an error from time to time so I had to create a pic with the name "-1.gif"
<SCRIPT language=javascript type=text/javascript>
//total image files
nTotal=26;
var pix = new Array();
var urlbase = 'http://localhost';
var pixidx = 0;
for (var i=0; i < 0; i++) {
r = Math.round(Math.random() * (nTotal-1));
pix[pixidx++] = urlbase + "/images/marquee/bw/" + r + ".gif";
}
for (var i=0; i < 9; i++) {
r = Math.round(Math.random() * (nTotal-1));
pix[pixidx++] = urlbase + "/images/marquee/bw/" + r + ".gif";
}
// getUniqueImage()
// Returns an index for the pix[] array that (probably) contains a unique image
function getUniqueImage()
{
for (var j=0; j<pix.length; j++) {
duplicate = false;
for (var i = 1; i < 9; i++)
{
if(document.images[i].src.indexOf(pix[j])!= -1)
{
duplicate=true;
}
}
if (!duplicate) {
return j;
}
}
// Couldn't find a non-duplicate so pick one at random
numRandom=Math.round(Math.random() * (pix.length - 1));
return numRandom;
}
function changeAuto()
{
indSrc = getUniqueImage();
indImg = Math.round(Math.random()*7)+1;
tmp = document.images[indImg].src;
document.images[indImg].src = pix[indSrc];
pix[indSrc] = tmp;
delay = 500;
setTimeout("changeAuto()", delay);
}
// Now make sure changeAuto() gets called on loading.
window.onload = changeAuto;
</SCRIPT>