What am I doing wrong?
var backgrounds = new Array("images/tiles/pattern_044.gif","images/tiles/pattern_045.gif","images/tiles/pattern_046.gif");
// setEvents is triggered by onload in the body tag
function setEvents() {
changeBkg();
}
function changeBkg() {
if (document.body) {
alert(backgrounds[0]); //this gives me [B]images/tiles/pattern_044.gif[/B] as expected
// document.body.style.backgroundImage="\\"url("+'+backgrounds[0]+'+")\\""; // [B]this didn't work[/B]
// document.body.style.backgroundImage="url('backgrounds[0]')"; // [B]this didn't work[/B]
document.body.style.backgroundImage="url('images/tiles/pattern_044.gif')"; // [B]this works but I want to use the array[/B]
}
}
all I want to do is set backgroungImage using an item from the array