Originally Posted by BigBody
like you had at first, should work fine. BUT, this method can only be used on a body tag that has already been parsed by the browser. In other words, if the code is in the head and not executed 'onload', then there is no body yet, as far as the browser is concerned, so nothing to do. If possible, it is much easier to put the script containing this code in the body section of the page. That way the browser will have already 'seen' the body tag and can assign your style to it.
document.body.style.backgroundImage = "url('bg.gif')"