Real Mouse Out Detection
When you have a DIV around a DIV (as example for design/layout reasons) and you want to detect the mouse out of the parent DIV, it does not work by simply using the event handler onmouseout="" in the nested DIV. For that, you need to use a workaround function like this:
// Javascript function for detecting the real mousout of a DIV element
// To use this as example in a DIV when you want to hide the DIV when
// you move your mouse out.
// <div onmouseout="if(mouseout(this,event)) this.style.display='none'">bla bla</div>
<script language="javascript">
function mouseout(t,e) {
if(e.relatedTarget)
return(e.relatedTarget != t && e.relatedTarget.parentNode != t);
return(e.toElement != t && e.toElement.parentNode != t);
}
</script>
|
|
Description
Usage Example:
<div>
<div c onmouseout="if(mouseout(this,event)) this.style.display='none'">
... bla bla bla
</div>
</div>
Top