程序代码:
<script>
//获得对像绝对位置
var divtop,divleft
function getIE(e){
var objtop=e.offsetTop;
var objleft=e.offsetLeft;
while(e=e.offsetParent) {
objtop+=e.offsetTop;
objleft+=e.offsetLeft;
}
divtop = objtop
divleft = objleft
}
//参考对象处显示对象位置,绝对位置
function Odiv(obj,div,yplace,xplace){
getIE(obj)
if (div.style.display=="none"){
div.style.left = divleft + xplace;
div.style.top = divtop + yplace;
div.style.display = "";
}else{
div.style.display = "none"
}
}
</script>
<a href="####" onclick="Odiv(this,ddd,0,0)">点我</a>
<div id="ddd" style="position:absolute;display:none; border:1px solid #000; width:200px; height:200px">我出来了</div>
临时搞个给你