By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,289 Members | 3,049 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,289 IT Pros & Developers. It's quick & easy.

Why does onMouseOver fire twice?

P: n/a
Hi,

I wrote code to highlight cells in an HTML table when the mouse flies over
them.
The code works well, except for a strange problem:
When the mouse enters a cell, I get 3 events for the cell: MouseOver;
MouseOut; MouseOver.
Then when the mouse leaves the cell, I also get 3 events: MouseOut;
MouseOver; MouseOut. (And 3 more when it enters the neighbouring cell)
Of course, I expected a single MouseOver on entry, and a single MouseOut on
exit.

I suspect something related to style, as if I enter a cell moving the mouse
very very slowly, I get the 1st MouseOver on the first pixel. As long as I
stay there, nothing more occurs. Then when I move 1 more pixel inwards I get
the MouseOut event. Finally moving in a third pixel, I get the last
MouseOver event. Then I can move the mouse anywhere inside that 3-pixel
boundary with no further events.
I've set margin: 0; padding: 0; border-width:0 in the CSS, but this does not
resolve the problem.

Both IE6 and NS6 behave the same way, which seems to mean it's my code (or
my expectations) that's wrong.

The code is visible online at http://ashpgvl.free.fr/voiles/.
The only visible effect of the extra 2 events is a slight flash of the
message displayed in the status bar when passing that 2nd pixel boundary.

Any idea?
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Jean-Francois Larvoire" <jf*********@wanadoo.fr.fr.fr.fr> wrote in message news:cg**********@news-reader3.wanadoo.fr...
Hi,

I wrote code to highlight cells in an HTML table when the mouse flies over
them.
The code works well, except for a strange problem:
When the mouse enters a cell, I get 3 events for the cell: MouseOver;
MouseOut; MouseOver.
Then when the mouse leaves the cell, I also get 3 events: MouseOut;
MouseOver; MouseOut. (And 3 more when it enters the neighbouring cell)
Of course, I expected a single MouseOver on entry, and a single MouseOut on
exit.

I suspect something related to style, as if I enter a cell moving the mouse
very very slowly, I get the 1st MouseOver on the first pixel. As long as I
stay there, nothing more occurs. Then when I move 1 more pixel inwards I get
the MouseOut event. Finally moving in a third pixel, I get the last
MouseOver event. Then I can move the mouse anywhere inside that 3-pixel
boundary with no further events.
I've set margin: 0; padding: 0; border-width:0 in the CSS, but this does not
resolve the problem.

Both IE6 and NS6 behave the same way, which seems to mean it's my code (or
my expectations) that's wrong.

The code is visible online at http://ashpgvl.free.fr/voiles/.
The only visible effect of the extra 2 events is a slight flash of the
message displayed in the status bar when passing that 2nd pixel boundary.

Any idea?



Well one thing that is strange and this is in IE 5.5 SP2. I do not experience the flicker you mention but I am getting
this. As I move the mouse over a cell the cursor changes to a hand. But if I move the mouse slowly to the left just
before the border of the cell the mouse changes to a cross signifying I can enter text or in fact the cell is no longer
clickable as a link. This behavior only occurs on the left side of the cell. I go from yellow to blue move the cursor
slowly to the left and just before the border the mouse icon changes from a hand to the cross. So it seems to me there is a variation in properties of the body of the cell.
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.