[Javascript] ONMOUSEOUT being triggered too many times

Parkes, Rohan parkesr1 at anz.com
Tue Aug 14 19:46:40 CDT 2001


What's wrong is that you have the event-handler at the top of an element
tree. You have to take into account the event-bubbling behaviour of IE -
events bubble up from lower elements to higher ones. Consequently, the table
elements generate their own events, which are cpatured by the onmoueout in
the top DIV.
 
Unfortunately, you can't turn event-bubbling off at the top level, as you
can in NS (one of NS's very few advantages over IE). Instead, you have to
add an attribute to each lower element whose event bubble you want to
disable:
 
event.cancelBubble="true"
 

Rohan Parkes 


-----Original Message-----
From: Lau [mailto:lau at goldenweb.com.au]
Sent: 14 August 2001 19:06
To: javascript at LaTech.edu
Subject: [Javascript] ONMOUSEOUT being triggered too many times



Hi all,

How do I get around this problem?
I have a DIV with a TABLE in it that I'm using as a popup menu.
Its initially HIDDEN and becomes VISIBLE when the cursor moves over a link.
So when the mouse leaves the DIV I want the menu to become HIDDEN again.
Sounds easy but the problem is that I'm getting the ONMOUSEOUT event being
triggered when the cursor
moves from one table row to the next, followed by another ONMOUSEOVER as it
enters the next row.

Here's sample code demonstrating the problem:

<DIV ID=menu STYLE='position: absolute; left: 200px; top: 300px;visibility:
visible'
onmouseover='alert("in");' onmouseout='alert("out");'>
<TABLE WIDTH=120 BORDER=1 CELLPADDING=0 CELLSPACING=0>
<TR><TD>option1</TD></TR>
<TR><TD>option2</TD></TR>
</TABLE>
</DIV>


regards
Lau



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20010815/9785c898/attachment.htm>


More information about the Javascript mailing list