<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>elementFromPoint|explicitOriginalTarget</title>
<script type="text/javascript">
/*
利用document.onmousemove方法检测鼠标移动
然后IE和OP都有document.elementFromPoint方法可以求出某点的对象
FF则可以用event.explicitOriginalTarget得出目前触发over的对象。。。
这样就得到了当前鼠标经过的对象。。。
*/
document.onmousemove = function (e) {
var e = window.event || e;
alert(document.elementFromPoint);
document.getElementById("status").innerHTML = (
document.elementFromPoint ? document.elementFromPoint(
e.clientX + document.documentElement.scrollLeft, e.clientY + document.documentElement.scrollTop
) : e.explicitOriginalTarget
).id;
};
</script>
</head>
<body>
<div id="status" style="background-color:#6699CC; border:#000000 1px solid;"></div>
<div id="f1" style="width:100px; height:200px; background-color:#000000;">
<div id="f11" style="width:50px; height:100px; background-color:#CCCCCC;"> </div>
</div>
<div id="f2" style="width:100px; height:50px; background-color:#FF0000;"> </div>
</body>
</html>