Return to Snippet

Revision: 5364
at March 3, 2008 12:05 by Winkyboy


Initial Code
// from http://www.dynamic-tools.net/toolbox/isMouseLeaveOrEnter/
// this function determines whether the event is the equivalent of the microsoft 
// mouseleave or mouseenter events. 
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); 
}

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

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

Initial Title
Mouseover / mouseout event fix: isMouseLeaveOrEnter

Initial Tags
event

Initial Language
JavaScript