Revision: 34568
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 25, 2010 17:05 by bullzito
Initial Code
<script type="text/javascript"> // # of images var imgCount = 4; // image directory var dir = 'http://yourdomain.com/images/bg/'; // random the images var randomCount = Math.round(Math.random() * (imgCount - 1)) + 1; // array of images & file name var images = new Array images[1] = "1.jpg", images[2] = "2.jpg", images[3] = "3.jpg", images[4] = "4.jpg"; document.body.style.backgroundImage = "url(" + dir + images[randomCount] + ")"; </script>
Initial URL
http://marioluevanos.com/playground/Random%20Background/
Initial Description
Place this script inside your <BODY> tag. Make sure to change the number of images, image directory and the file names in the array.
Initial Title
Random Background Image
Initial Tags
Initial Language
JavaScript