<style>
#div1 {background: green}
#div2 {background: yellow}
</style>
<div id="div1">div1
<div id="div2">div2
</div>
</div>
<script>
window.onload = function () {
var div1 = document.getElementById('div1');
div1.onmouseout = function (e) {
e = e || window.event;
var rt = event.relatedTarget || event.toElement;
while (rt && rt !== this) rt = rt.parentNode;
if (rt == this) return; else alert('hy');
}
}
</script>