buildrebuild
01-07-2007, 01:42 PM
Hi,
I need help randomizing the background image. I have tried but nothing seems to work. Here is what I have so far and it works, but this is just a single image.
PS This has to stay unobtrusive!
<script language="javascript">
function setStyles(el, css) {
var l = el.length;
if (typeof l == 'undefined') {el = [el]; l = 1;}
for (var i=0; i<l; i++) {
for (var s in css) el[i].style[s] = css[s];
}
}
window.onload = function() {setStyles(document.body, {background:'url(images/studio.gif) repeat-x top'});
}
</script>
Thx everyone,
CB
I need help randomizing the background image. I have tried but nothing seems to work. Here is what I have so far and it works, but this is just a single image.
PS This has to stay unobtrusive!
<script language="javascript">
function setStyles(el, css) {
var l = el.length;
if (typeof l == 'undefined') {el = [el]; l = 1;}
for (var i=0; i<l; i++) {
for (var s in css) el[i].style[s] = css[s];
}
}
window.onload = function() {setStyles(document.body, {background:'url(images/studio.gif) repeat-x top'});
}
</script>
Thx everyone,
CB