var the = event.srcElement ;function getPosition( the )
{
var x = the.offsetWidth;
var y = the.offsetTop ;
var the2 = the ;
while( the2 && the2.offsetTop && the2.offsetWidth )
{
x += the2.offsetWidth ;
y += the2.offsetTop ;
the2 = the2.parentNode ;
}
}
{
var x = the.offsetWidth;
var y = the.offsetTop ;
var the2 = the ;
while( the2 && the2.offsetTop && the2.offsetWidth )
{
x += the2.offsetWidth ;
y += the2.offsetTop ;
the2 = the2.parentNode ;
}
}
源代码如下:
<script language="javascript" type="text/javascript">
function missde(o){
t=document.getElementById("menu")
k=t.style
k.display=""
k.pixelTop=o.offsetHeight+o.offsetTop+1
k.pixelLeft=o.offsetLeft+(o.offsetWidth-t.offsetWidth)/2
}
function no(){
document.getElementById("menu").style.display="none"
}
</script>
<center>
<input type="text" name="textfield" onMouseOver="missde(this)" onMouseOut="no()">
<div id="menu" style="border:1px solid #ff0000;width:50px;height:30px;position:absolute;zIndex=100;display:none; background-color:#CCCCCC" >d</div></center>
这个位置由于表格的问题,而变得不行了,请指点如何修改。
<!--
function missde(){
t=document.getElementById("menu")
o=document.getElementById("td")
k=t.style
k.display=""
k.pixelTop=o.offsetHeight+o.offsetTop+1
k.pixelLeft=o.offsetLeft+(o.offsetWidth-t.offsetWidth)/2
}
function no(){
document.getElementById("menu").style.display="none"
}</script></head>
<div id="menu" style="border:1px solid #ff0000;width:50px;height:30px;position:absolute;zIndex=100;display:none; background-color:#CCCCCC" >d</div>
<body>
<table width="175" height="27" border="0" cellpadding="1" cellspacing="0">
<tr>
<td height="25" id="td"><form name="form1" method="post" action="">
<input type="text" name="textfield" onMouseOver="missde()" onMouseOut="no()">
</form></td>
</tr>
</table>
</body>
</html>