[Javascript] MouseOver changes Background

Peter Brunone peter at brunone.com
Tue Jul 6 11:08:36 CDT 2004


Add the following attributes to your link (I know this works in IE, but there may be a subtle change for the Mozilla DOM):

onMouseOver="document.body.style.backgroundColor='lightgreen';"

   To set the color back, use the onMouseOut event handler.  Of course you'll probably want to call a function from the event handlers and let the function do the color switching, but you get the idea.

Cheers,

Peter  

Original Message:
>From: Scott Hamm <ScottHam at clientlogic.com>

>to the body.
>
>> -----Original Message-----
>> From:	javascript-bounces at LaTech.edu [SMTP:javascript-bounces at LaTech.edu]

>>    The background of the body, or the link, or something else?
>> 
>> Original Message:
>> >From: Scott Hamm <ScottHam at clientlogic.com>
>> 
>> >I got a list of colors and would like to write JavaScript that changes
>> >background when mouse hoovers over anchored link:
>> >
>> >My existing code is as follows:
>> ><ul>
>> ><li>
>> >	<a href="LTGREEN.html" title="LightGreen"
>> >style="background:#90ee90;">
>> >		<p class=name>LightGreen</p>
>> >		<p class=num>144 238 144</p>
>> >		<p class=webid>#90EE90</p>
>> >	</a>
>> ></li>
>> ><snip>
>> ></ul>





More information about the Javascript mailing list