为什么还没有移开div在区域内就响应onmouseout了
应该是div的鼠
标响应事件的问题,为什么还没有鼠标移开div在区域内就响应onmouseout了
这是两个层,鼠标放底下层后,弹出详细层,将低层覆盖,现在问题是,
为什么还没有鼠标移开div在区域内就响应onmouseout了
<div id= "menu2 " class= "plist " onmouseover= "over_forshow(this, 'showdetails2 ') " />
</div>
<div id= "showdetails2 " class= "plist2 " onmouseout= "over_forshowclose( 'showdetails2 '); " > </div>
------解决方案--------------------这个应该和你问的问题类似吧。
</style> <br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<table id= "ta " width= "350 " border= "0 " cellspacing= "0 " cellpadding= "0 ">
<tr>
<td bgcolor= "#996633 "> </td>
<td bgcolor= "#234633 "> <button > Clos </button> </td>
<td bgcolor= "#0000FF "> </td>
</tr>
</table>
<script type= "text/javascript ">
var rePosition = function (o) {
//获取元素绝对位置
var $x = $y = 0;
do {
$x += o.offsetLeft;
$y += o.offsetTop;
} while ((o = o.offsetParent));
return { x : $x, y : $y };
};
window.onload = function () {
var wc = document.getElementById( "ta "), ing = false;
wc.onmouseover = function () {
if (!ing) {
ing = true;
alert( "over ");
}
};
wc.onmouseout = function () {
var wc = this, e = window.event || e,
x = document.body.scrollLeft + e.clientX, y = document.body.scrollTop + e.clientY, p = rePosition(wc);
//alert(y);
if (x <= p.x || x > = (p.x + wc.offsetWidth) || y <= p.y || y > = (p.y + wc.offsetHeight)) {
alert( "out ");
ing = false;
}
};
};
</script>
------解决方案--------------------如果 (event.fromElement!=event.toElement) && (this.contains(event.toElement) )
就触发onmouseover事件一次
如果 (event.fromElement!=event.toElement) && (this.contains(event.fromElement) )
就触发onmouseout事件一次
如果 (!this.contains(event.fromElement)) && (this.contains(event.toElement) )
就触发onmouseenter事件一次
如果 (!this.contains(event.toElement)) && (this.contains(event.fromElement) )
就触发onmouseleave事件一次
有关onmouseover和onmouseout
http://jkisjk.spaces.live.com/blog/cns!758CACE25E89DD3B!397.entry