Recently write something, more annoying, a pop-up layer, there are other elements above, the intention is that the mouse left the pop-up layer, perform some action, but in practice, the mouse left the pop-up layer elements, will also activate these actions. The method of stopping event bubbling for each browser is not valid.
Or we javaeye many, in a buddy blog found the following code:
Copy Code code as follows:
function Ismouseleaveorenter (e, handler) {
if (e.type!= ' mouseout ' && e.type!= ' MouseOver ') return false;
var RELTG = E.relatedtarget? E.relatedtarget:e.type = ' mouseout '? E.toelement:e.fromelement;
while (RELTG && RELTG!= handler)
RELTG = Reltg.parentnode;
Return (RELTG!= handler);
}
This method is to determine whether the current element is the element that is going to execute the Mouseout event, so that the above problem can be avoided.