Javascript and Table Properties

They have: 601 posts

Joined: Nov 2001

Hi

I'm using the following code to make a TD cell clickable (please rip this code to shreds if you can find a better way to do this, or a way to combine the two tags - I am in *no way* a Javascript guru).

<td OnClick="javascript:location.href='http://localhost/r';"
style="cursor:hand;">
'
Now what I'd like to do is when the Mouse runs over the cell, it changes the background colour to white. I've tried:

OnMouseOver="bgcolor:#FFFFFF"
and
OnMouseOver="background:#FFFFFF"
'
Neither of which wants to work. Does anyone know how to do this? Do I have to name my TD cell and then reference it via document.td.tdname?

Thanks

- wil

mairving's picture

They have: 2,256 posts

Joined: Feb 2001

Try this:

<bgcolor="#color1"
onMouseOut="this.style.backgroundColor='#color1';"
onMouseOver="this.style.backgroundColor='#color2';"
'
It only works in IE and newer versions of NS.

Mark Irving
I have a mind like a steel trap; it is rusty and illegal in 47 states

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

I edited the code samples to kill the wicked scroll in the forums.

There shouldn't be any hard returns in JavaScript, but there can be between attributes in HTML. Feel free to remove them if you cut and paste the code.

Smiling Suzanne

They have: 601 posts

Joined: Nov 2001

Sorry, I always forget that people are on smaller monitors than I Wink

Thanks.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.