Tuesday, December 1, 2009

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!



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





%26lt;body onload="backImage()"%26gt;



%26lt;/body%26gt;



%26lt;script language=Javascript%26gt;



var images = new Array("image1.jpg" , "image2.jpg" , "image3.jpg" , "image4.jpg");



function backImage() {



document.body.background =



images[Math.floor( Math.random() * images.length)];



}



%26lt;/script%26gt;



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.

No comments:

Post a Comment

 
free adware remover