欢迎来到福编程网,本站提供各种互联网专业知识!

Code:findPosX 和 findPosY

发布时间:2006-12-20 作者: 来源:转载
/***FindtheXpositionofanobject,relativetotheviewport*Codecopiedfromquirksmode.org*@paramobjObjecttofindxpositionfor*/functionfindPosX(obj){varcurleft=0;if(obj.offsetParent){while(obj.offsetParent){curleft+=obj.offsetLeftobj=obj.offsetParent
/**
*FindtheXpositionofanobject,relativetotheviewport
*Codecopiedfromquirksmode.org
*@paramobjObjecttofindxpositionfor
*/
functionfindPosX(obj)
{
varcurleft=0;
if(obj.offsetParent)
{
while(obj.offsetParent)
{
curleft+=obj.offsetLeft
obj=obj.offsetParent;
}
}
elseif(obj.x)
curleft+=obj.x;
returncurleft;
}

/**
*FindtheYpositionofanobject,relativetotheviewport
*Codecopiedfromquirksmode.org
*@paramobjObjecttofindypositionfor
*/
functionfindPosY(obj)
{
varcurtop=0;
if(obj.offsetParent)
{
while(obj.offsetParent)
{
curtop+=obj.offsetTop
obj=obj.offsetParent;
}
}
elseif(obj.y)
curtop+=obj.y;
returncurtop;
}

相关推荐