View Full Version : Changing textcolor on MouseOver

07-26-2002, 11:59 AM

I'm new to JavaScript so this may sound stupid, but I can't change my textcolor on mouseover.

This is my code:
<td class="linkCursor">
<a onClick="top.window.close()" onMouseover="this.style.fontColor='blue'">Sluit

The linkCursor class only changes the cursor into a hand so that it looks like a regular link.

I've looked on a tutorial site and came up with the this.style.backgroundColor='blue' but it seems fontColor does not work. Nor does color or textColor by the way.

Thanks a lot,


07-26-2002, 01:14 PM
<a onClick="top.window.close()" onMouseover="this.style.color='blue'">Sluit

This works for me in IE5.5 and Mozilla 1.0. Probably you tested this in NN4.7, but this syntax to manipulate styles on the fly is not (and will never) be supported by NN4 or older browsers.

07-26-2002, 02:24 PM
I tested it in IE 6 and it didn't work, maybe a syntax error, I'll try again. :)


Roy Sinclair
07-26-2002, 08:43 PM
I tried what Modred gave you and it worked just fine. Since NS4 doesn't seem to be an issue why not use pure CSS instead of Javascript in the first place:

... in the <head>
<style type="text/css">
a.hotlink:hover { color: blue; }

.. in the <body>

<a onClick="top.window.close()" id="hotlink">Sluit venster</a>

Of course the code above will also cause the link to revert when the mouse move off of it.