Published  at  06:47 AM
Image for Random Background Images Script

Random Background Images Script

Random Background Images Script

This code is used if you want a different background every time you refresh your blog/theme.

src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script>
<script type="text/javascript">
// <![CDATA[
var image_array = new Array();
image_array[0] = "IMAGEURL";
image_array[1] = "IMAGEURL";
image_array[2] = "IMAGEURL";
image_array[3] = "IMAGEURL";
image_array[4] = "IMAGEURL";

var rand_path = image_array[Math.floor(Math.random() * image_array.length)];

$(document).ready(function() {
$("body").css('background-image', 'url('+rand_path+')');
});
// ]]>
</script>

If you want to add more image, add this part after the last image_array:

image_array[PREVNUMBER+1] = "IMAGEURL";

Also if you want apply that to other places’ background other than the body background, change body to the div name of the place (ex: #sidebar, .post).