Actually, djr33 is right. Using this script with a normally-laid-out site, you're going to end up with something that looks like this (after the script has run):
Code:
<head>
<body bgcolor='#000000' text='#ffd700'link='#ffa500' vlink='#cc0000' alink='#ffa500' background='seventh.gif'>
</head>
<body>
... rest of page ...
This is not well-formed HTML. One solution would be, as djr33 suggested, to put the script in the place of the <body> tag. However, this will destroy the page in non-JS browsers. The correct way to do this would be:
Code:
<head>
<title></title>
<script type="text/javascript">
onload = function() {
bg = new Array("firstimage.gif", "secondimage.jpg", "thirdimage.png", "fourthimage.tif"/*, ... */);
var Numb = Math.floor(bg.length * Math.random());
document.body.style.backgroundImage="url(" + bg[Numb] + ")";
};
</script>
</head>
Bookmarks