PDA

View Full Version : Random Headers on a HTML Page



tomyknoker
05-24-2006, 02:00 PM
I have 5 images set up to fit within the header on my web page. I want each time the pages loads to randomly display 1 of the 5 images in the header... Is this complicated? Anyone got any ideas?

Thanks,
Tom

Twey
05-24-2006, 02:17 PM
In Javascript? Not really.

<img src="image1.png" name="headerImage">
<script type="text/javascript">
window.onload = function() {
var images = ["image1.png", "image2.png", "image3.png"]; // Add more if you like
document.images['headerImage'].src = images[Math.floor(Math.random() * images.length)];
};
</script>

tech_support
05-26-2006, 07:47 AM
Like mess.be?

What he said. ^ UP THERE ^