[Javascript] MouseOver changes Background

Flavio Gomes flavio at economisa.com.br
Tue Jul 6 11:24:02 CDT 2004


  From his list I think he wants to treat each paragraph according to 
it's classname, so the problem I'm having is to find out the .className 
of the paragraph that the mouse just passed over, this code "works" but 
sometimes it brings an error of "oTarget has no properties", someone has 
an suggestion to improve it?


=========//=========
function checkClass(e)
{
  document.title = y++;

 oTarget = e.relatedTarget;
 if (oTarget.tagName=='P')
    alert(oTarget.className);
}
onmouseover = checkClass;
=========//=========

.relatedTarget is according to mozilla DOM, for IE would it be .srcElement?


---
Flavio Gomes
flavio at economisa.com.br



Peter Brunone wrote:

>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>
>>>>        
>>>>
>
>
>_______________________________________________
>Javascript mailing list
>Javascript at LaTech.edu
>https://lists.LaTech.edu/mailman/listinfo/javascript
>  
>



More information about the Javascript mailing list