Posted By

Winkyboy on 03/03/08


Tagged

event onmouseover onmouseout bubbling


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

adix
SpinZ
wizard04


Mouseover / mouseout event fix: isMouseLeaveOrEnter


 / Published in: JavaScript
 

URL: http://www.dynamic-tools.net/toolbox/isMouseLeaveOrEnter/

Usage: onmouseout='if (isMouseLeaveOrEnter(event, this)) YourActionHere();' onmouseover='if (isMouseLeaveOrEnter(event, this)) YourOtherActionHere();'

  1. // from http://www.dynamic-tools.net/toolbox/isMouseLeaveOrEnter/
  2. // this function determines whether the event is the equivalent of the microsoft
  3. // mouseleave or mouseenter events.
  4. function isMouseLeaveOrEnter(e, handler)
  5. {
  6. if (e.type != 'mouseout' && e.type != 'mouseover') return false;
  7. var reltg = e.relatedTarget ? e.relatedTarget :
  8. e.type == 'mouseout' ? e.toElement : e.fromElement;
  9. while (reltg && reltg != handler) reltg = reltg.parentNode;
  10. return (reltg != handler);
  11. }

Report this snippet  

You need to login to post a comment.