87,915
社区成员
发帖
与我相关
我的任务
分享
var obj = null;
if (window.event) {
if (sign) {
obj = event.fromElement;
} else {
obj = event.toElement;
}
} else {
obj = e.relatedTarget;
}
while (obj!=null && obj.id!='divA_ID') { // ID of the divA
obj = obj.parentNode;
}
if (obj==null) {
// Add Your Code Here
...
}
<html><head><meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css"><!--
a, a:link{text-decoration: none; color:#000000; font-size:9pt;} a:visited{text-decoration: none; color:#000000;} a:hover{text-decoration: underline; color:red;}
body, td, p, li, div, select{font-size:9pt; font-family:"宋体";}
--></style>
<script language="javascript" type="text/JavaScript">
function getOffset(el,isLeft){var retValue=0;while(el!=null){retValue += el['offset'+(isLeft?'Left':'Top')];el=el.offsetParent;}return retValue;};
var oN=null;
function ove(o)
{
var p=0, b=document.getElementById("tB");
if(o!=b)
{
p=1;
oN=o;
}
b.style.display='block';
b.style.top=getOffset(o,false)+p;
b.style.left=getOffset(o,true)+(o.offsetWidth-b.offsetWidth)-p;
b=null;
}
function out(o)
{
var b=document.getElementById("tB");
b.style.display='none';
b=null;
}
function cli(o)
{
var s='你在 '+oN.id+' 区点击了B';
document.getElementById('TX').value=s;
}
</script>
</head>
<body>
<input type="text" id="TX" />
<br /><br /><br />
<div id="tA" onmouseover="ove(this);" onmouseout="out(this);" style="width:100px;height:80px;border:1px blue solid;text-align:center;line-height:80px;">A</div>
<br /><br /><br />
<div id="tC" onmouseover="ove(this);" onmouseout="out(this);" style="width:100px;height:80px;border:1px blue solid;text-align:center;line-height:80px;">C</div>
<br /><br /><br />
<div id="tB" onmouseover="ove(this);" onmouseout="out(this);" onclick="cli(this)" style="position:absolute;z-index:100;width:30px;height:20px;border:1px red solid;text-align:center;background:#FF9966;display:none;">B</div>
</body>
</html>