Forum Moderators: open
-----------------------
myPics = new Array("image1.jpg", "image2.jpg", "image3.jpg")
imgCt = myPics.length
randomNum = Math.floor((Math.random() * imgCt))
function randomPic() {
document.myImage.src = myPics[randomNum]
}
------------------------
Thanks!
as penders has pointed out, this requires a cookie. ;)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><script type="text/javascript">
<!--var num;
var myPics=new Array('image1.jpg','image2.jpg','image3.jpg');
var imgCt=myPics.length;function testNumber() {
randomNum=Math.floor(Math.random()*imgCt);
if(randomNum==num) {
testNumber();
}
else {
num=randomNum;
document.getElementById('myImage').src=myPics[randomNum];
setCookie();
}
}function setCookie() {
exp=new Date();
plusMonth=exp.getTime()+(31*24*60*60*1000);
exp.setTime(plusMonth);
document.cookie='Number='+num+';expires='+exp.toGMTString();
}function readCookie() {
if(document.cookie) {
num=document.cookie.split('Number=')[1];
testNumber();
}
else {
testNumber();
}
}
window.onload=readCookie;
//-->
</script></head>
<body><div>
<img id="myImage" src="" alt=""/>
</div></body>
</html>
birdbrain