Events problems

N

Niko

Hello,

Context :

Dom Structure

DIV
|->TABLE
|->TR
|->TD
| |->textNode
|
|->TD
| |->IMG
|
|->TD
|->textNode

I have added mouseover and mouseout events on the DIV element.

I need thoses events only triggered when the mouse goes in and out of
the div but actually (with IE7) they are triggered if the mouse going
out of a Table cell to go in the adjacent cell.

I suppose a propagation pb but I don't know how to limit the event
attachement to the div only without any propagation to enbedded objects.

Thanks

Best regards

Niko
 
R

Rik Wasmus

Hello,

Context :

Dom Structure

DIV
|->TABLE
|->TR
|->TD
| |->textNode
|
|->TD
| |->IMG
|
|->TD
|->textNode

I have added mouseover and mouseout events on the DIV element.

I need thoses events only triggered when the mouse goes in and out of
the div but actually (with IE7) they are triggered if the mouse going
out of a Table cell to go in the adjacent cell.

I suppose a propagation pb but I don't know how to limit the event
attachement to the div only without any propagation to enbedded objects.

Pretty well explained:
http://www.quirksmode.org/js/events_mouse.html
 
J

Jorge

Hello,

Context :

Dom Structure

DIV
  |->TABLE
       |->TR
           |->TD
          |   |->textNode    
           |
           |->TD
          |   |->IMG
           |
           |->TD
              |->textNode

I have added mouseover and mouseout events on the DIV element.

I need thoses events only triggered when the mouse goes in and out of
the div but actually (with IE7) they are triggered if the mouse going
out of a Table cell to go in the adjacent cell.

I suppose a propagation pb but I don't know how to limit the event
attachement to the div only without any propagation to enbedded objects.

Thanks

Best regards

Niko

div.onmouseover= function (event) {
var event= event || window.event;
if (event.target !== this) { return; }
//DoYourThingsHere
}

But, ISTM that IE's 'event' object lacks a 'target' property (?) so...
somebody else may want help you better than I.
 
J

Justin McConnell

div.onmouseover= function (event) {
  var event= event || window.event;
  if (event.target !== this) { return; }
  //DoYourThingsHere

}

But, ISTM that IE's 'event' object lacks a 'target' property (?) so...
somebody else may want help you better than I.

IE sets the srcElement property.

div.onmouseover= function (event) {
var event = event || window.event;
var targ = event.target || event.srcElement;
if (targ !== this) { return; }
//DoYourThingsHere
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top