[Javascript] hide div in mouseout

Michael Borchers list at tridemail.de
Fri Dec 21 04:35:40 CST 2007


----- Original Message ----- 
From: "Matt Evans" <fatpratmatt at gmail.com>
To: "JavaScript List" <javascript at lists.evolt.org>
Sent: Thursday, December 20, 2007 9:06 PM
Subject: Re: [Javascript] hide div in mouseout


> Hi,
>
> Try this:
>
> div.onmouseout = function(event) {
>  if (checkMouseLeave(this, event)) {
>    hide();
>  }
> };
>
> I did a quick test and it seemed to work fine in FF2 and IE7 here
>
> Thanks,
> Matt
 First of all thanks since the syntax is the correct one.
Unfortunately the "checkMouseLeave" function causes probs in IE6,
the toElement method won't work (toElement empty or undefined)!

function checkMouseLeave (element, evt) {
  if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

There seems to be a workaround here:
http://www.mediaevent.de/javascript/event_properties.html

Does anyone have a different or fully compatible "checkMouseLeave" function?

I wonder if there is one in the prototype framework... 




More information about the Javascript mailing list