Forum Moderators: not2easy

Message Too Old, No Replies

backgroundColor style change doesn't work in netscape

is there a way to fix it?

         

Tokey

6:30 am on Jun 24, 2003 (gmt 0)

10+ Year Member



Hello. I have links inside <TD> tags on my site. When you mouseover them, its supposed to change the background color of the <TD> to create a lighting up button effect.

Suppose my <TD>'s ID is "button." This onmouseover code will work in IE 5 and 6, but not Netscape:

onmouseover="button.style.backgroundColor='#5778E1';"

Can anyone tell me what I'm doing wrong? Thanks...

stickledene

6:39 am on Jun 24, 2003 (gmt 0)

10+ Year Member



could be something simple like

onMouseOver and not onmouseover

Tried that?

*added*

Oops, and sorry! Welcome to WebmasterWorld!

Tokey

7:00 am on Jun 24, 2003 (gmt 0)

10+ Year Member



thanks for the welcome.

caps don't matter for onMoUsEoVEr, or any attributes for that matter. I did some reading on other newsgroups and I have heard a lot of people lamenting that you can't dynamically change TD or TR background colors in Netscape. If that's true, I'll just have to try something else. :-(

grahamstewart

7:07 am on Jun 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well since you are posting to the CSS forum I would have thought the answer was obvious - try using CSS..


td {
padding: 0;
}
td a {
display: block;
width: 100%;
height: 100%;
}
td a:hover {
color: #fff;
background-color: #5778e1;
}

outrun

7:15 am on Jun 24, 2003 (gmt 0)

10+ Year Member



Yes CSS is a better way to go but if your intent on Javascript, which version of netscape are you have trouble with because the following works fine in later versions of netscape.

onMouseOver="this.bgColor='#CCCCCC';" onMouseOut="this.bgColor='#FFFFFF';"

Don't include onMouseOut if you want to keep the color after teh rollover.

regards,
Mark

stickledene

7:15 am on Jun 24, 2003 (gmt 0)

10+ Year Member



*bah, I really should refresh my browser once in a while - used the same code as posted above*

drbrain

5:11 pm on Jun 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



UTSL! (Use The Standards, Luke)

document.getElementById('button').style.backgroundColor = '#5778E1';

Mozilla doesn't have 'magic' id elements. Magic variables are the evilist of evil evils (which makes most PHP scripts evil). Magic encourages lazy, unmaintainable code.

If your browser supports :hover (really supports it, not just for <a> elements), you could do td:hover { background: #5778e1 }.

grahamstewart

10:30 pm on Jun 24, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



which makes most PHP scripts evil

Actually these days PHP comes with register_globals turned off by default - hence no magic variables.

you could do td:hover

Or just fill the <td> with the <a> and put the hover rule on that as I did above. :)