I have a web page that contains a bunch of advertisements. What I need to do it randomly shuffle these images each time the page is refreshed. I cannot have any repeating ads.
Here is the code I have now.... it repeats images.
<html>
<head>
<script type="text/javascript">
function random()
{
images = new Array(3);
images[0] = "<a href='http://www.xxxxxxxxxxxxx.ca' target='_blank'><img src='xxxxxxxx.jpg' alt='' /></a>";
images[1] = "<a href='xxxxxxxx' target='_blank'><img src='xxxxxxx.jpg' alt='' /></a>";
images[2] = "<a href='xxxxxxxx' target='_blank'><img src='xxxxxxxx.jpg' alt='' />";
for(var i = 0; i < images.length; i++)
{
index = Math.floor(Math.random() * images.length);
document.write(images[index]);
}
}
</script>
</head>
<body>
<script type="text/javascript">
random();
</script>
</body>
</html>
I would like to keep the code as simple as possible.