Forum Moderators: open
This is my first and not last post. I get alot of problems! :o)
Im creating a website at the moment and to be honest i have no javascript knowledge at all. I think this is the language to do this in though.
I need to make my website so when you could to the home page you get one image and then the next time you come you get a diffrent image. So for instance if you kept clicking refresh the image would rotate.
If someone could point me in the right direction or provide the code i would be very happy!
Thanks guys.
Dappa.
Here is a very simple script that may give you some ideas ;)...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta content="mshtml 6.00.2800.1264" name="generator" />
<title>Random Images</title><style type="text/css">
/*<![CDATA[*/body {
background:#dddddd;
}
div#container {
width:336px;
position:absolute;
top:100px;
left:50%;
margin-left:-168px;
}
img#random {
width:324px;
height:200px;
border:double 6px #000000;
}/*//]]>*/
</style><script type="text/javascript">
//<![CDATA[var images=new Array();
images[0]="image_1.jpg";
images[1]="image_2.jpg";
images[2]="image_3.jpg";
images[3]="image_4.jpg";
images[4]="image_5.jpg";
images[5]="image_6.jpg";
function randomImage() {
var i=Math.floor(Math.random()*images.length);
document.getElementById("random").src=images[i];
}
onload=randomImage;//]]>
</script></head>
<body ><div id="container">
<img id="random" src="" alt=""/>
</div></body>
</html>
birdbrain