diff --git a/lib/OpenLayers/Util.js b/lib/OpenLayers/Util.js index 58367baa9b..9b2121af9e 100644 --- a/lib/OpenLayers/Util.js +++ b/lib/OpenLayers/Util.js @@ -758,9 +758,12 @@ OpenLayers.Util.getTagText = function (parent, item, index) { * @return {boolean} */ OpenLayers.Util.mouseLeft = function (evt, div) { + // start with the element to which the mouse has moved var target = (evt.relatedTarget) ? evt.relatedTarget : evt.toElement; - while (target != div && target.nodeName != 'BODY') { + // walk up the DOM tree. + while (target != div && target != document.documentElement) { target = target.parentNode; } - return (target == div); + // if the target we stop at isn't the div, then we've left the div. + return (target != div); };