
Originally Posted by
BigBody
I'm using javascript not css, and bg.gif is in the same folder as the page. I tried
document.body.background = 'bg.gif'
but it still have wrong
What are you trying to do? Is this part of a script? As javascript code, it would need to be in order to do anything. If you have that happening then:
Code:
document.body.style.backgroundImage = "url('bg.gif')"
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.
Bookmarks