...

View Full Version : Random Headers on a HTML Page



tomyknoker
05-24-2006, 02:58 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

Kor
05-24-2006, 04:43 PM
<script type="text/javascript">
var pics=['pic1.jpg','pic2.jpg','pic3.jpg','pic4.jpg','pic5.jpg'];
onload = function(){
var myPic= document.getElementById('mypic');
myPic.src=pics[Math.floor(Math.random()*pics.length)]
}
</script>
......
.......
<img id="mypic" src="">



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum