Hmm.. do you want to add them to the backgr array, or the backgrounds array? Anyways, you did this?:
Code:
var x = ['bg1.jpg','bg2.jpg','bg3.jpg','bg4.jpg', 'bg5.jpg', 'bg6.jpg'];
And, I would suggest(to make this work, the only way), to replace all the:
Code:
Math.round(6*Math.random());
With:
Code:
Math.round(x.length*Math.random());
So basically your code would be this:
Code:
var backgr = ['bg1.jpg','bg2.jpg','bg3.jpg','bg4.jpg', 'bg5.jpg', 'bg6.jpg'];
var cur = Math.round((backgr.length)*Math.random());
document.write('<body background="'+backgr[cur]+'">');
var backgrounds = ['bg1.jpg','bg2.jpg','bg3.jpg','bg4.jpg', 'bg5.jpg', 'bg6.jpg'],
bg,
cur = Math.round((backgrounds.length)*Math.random());
document.body.style.backgroundImage=backgrounds[cur];
document.body.style.backgroundPosition="top center"; // can be changed to anything else (e.g. bottom center, top left, center right...)
document.body.style.backgroundRepeat="no-repeat";
Or just to be cleaner:
Code:
var backgr = ['bg1.jpg','bg2.jpg','bg3.jpg','bg4.jpg', 'bg5.jpg', 'bg6.jpg'];
document.write('<body background="'+backgr[cur]+'">');
bg,
cur = Math.round((backgr.length)*Math.random());
document.body.style.backgroundImage=backgr[cur];
document.body.style.backgroundPosition="top center"; // can be changed to anything else (e.g. bottom center, top left, center right...)
document.body.style.backgroundRepeat="no-repeat";
Bookmarks