Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Netscape's bgColor

Status
Not open for further replies.

jay25

MIS
Jun 17, 2002
16
US
I can't get this to work in Netscape. What is wrong? Can you not change the background color in Netscape dynamically?
Code:
<div id=&quot;box1&quot; style=&quot;background-color:#ccffcc;&quot;>
This is box 1 
</div>
<script language=&quot;JavaScript&quot;>
function color()    {
if (document.all)    {
box1.style.backgroundColor=&quot;blue&quot;;    }
else        {
box1.bgColor=&quot;blue&quot;;    }
}
</script>
[code]
Thanks.
 
According to Dynamic HTML:The Definitive Reference by Danny Goodman from O'Reilly, &quot;The lack of automatic content reflow in Navigator 4 prevents it from displaying most changes to style sheet attribute values after the document has loaded, even if the values are exposed to scripting.&quot;

I wonder, what about Netscape 6?

Also bgColor is a document property, so that might be the problem. Did you try box1.backgroundColor=&quot;blue&quot;;


 
I've tried box1.backgroundColor and document.box1.bgColor and I've tried Netscape6 but they wouldn't work. I think it's like you said, that you can only change the background in the whole document because document.bgColor did work. But I could not do it in a div.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top