...

View Full Version : Changing textcolor on MouseOver



Florens
07-26-2002, 12:59 PM
Hi,

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
venster</a></td>

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,

Florens

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

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.

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

Thanks

Roy Sinclair
07-26-2002, 09: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; }
</style>

.. 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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum