How can i use HTML code to make my site background change with each load?

if you go to www.mtv.com, and refresh a few times, you will notice that they have several different backgrounds that change each time you load the page. does anyone know coding i can use to do this too? not changing ever few seconds or at a set time interval, i know how to do that with GIF images. but with each load, theres a different background image. anyone? anyone? if anyone can help me out here, it would be greatly appreciated! thanks!

Public Comments

  1. <body onload="backImage()"> </body> <script language=Javascript> var images = new Array("image1.jpg" , "image2.jpg" , "image3.jpg" , "image4.jpg"); function backImage() { document.body.background = images[Math.floor( Math.random() * images.length)]; } </script> Pretty simple - when the page loads it sets the background image to a random selection from the array images. Set those images to your picture URLs to see.
Powered by Yahoo! Answers