[javascript]代码库
//获得控件的位置
function getAbsolutePosition(obj)
{
position = new Object();
position.x = 0;
position.y = 0;
var tempobj = obj;
while(tempobj!=null && tempobj!=document.body)
{
if(window.navigator.userAgent.indexOf("MSIE")!=-1)
{
position.x += tempobj.offsetLeft+4;
position.y += tempobj.offsetTop+5;
}
else
{
if(window.navigator.userAgent.indexOf("Firefox")!=-1)
{
position.x += tempobj.offsetLeft;
position.y += tempobj.offsetTop;
} else {
position.x += tempobj.offsetLeft+4;
position.y += tempobj.offsetTop+5;
}
}
tempobj = tempobj.offsetParent
}
return position;
}