Click to See Complete Forum and Search --> : onmouseout being signaled w/o leaving the element


delerious
12-10-2003, 03:23 AM
I have a DIV that contains some anchors arranged vertically. On the DIV element I have an onmouseout event handler. If I move the mouse over one of the anchors, and then move it to another anchor (while remaining inside the DIV), the onmouseout event handler gets triggered even though the mouse never went outside the DIV. This happens in IE, Opera, and Mozilla.

You can see this problem for yourself here:
http://home.comcast.net/~delerious1/index4.html

Does anyone know why this is happening?

Gollum
12-10-2003, 04:14 AM
From what I can gather about browser behaviour, only one HTMLElement can have mouseover at any one time. And any element that had mouseover but now doesn't aught to get a mouseout before anyone else get the mouseover.

So, if your div contains other HTML elements, when you pass from one part of the DIV to the contained element, the element must get an onmouseover event, so the DIV must get onmouseout.

I'm not saying this is a good way to do things, just that this seems to be what happens.

This way of course makes things easy for the browser writers. In fact, the onmouseout event is triggered by an onmouseover event on another element. You will notice that if you have an element on the edge of the window and quickly move the mouse off the window, you may not get an onmouseout event.

For more explanation you may need to go to the source (IE,Netscape,etc)