Code:findPosX 和 findPosY
更新時間:2006年12月20日 00:00:00 作者:
/**
* Find the X position of an object, relative to the viewport
* Code copied from quirksmode.org
* @param obj Object to find x position for
*/
function findPosX(obj)
{
var curleft = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
return curleft;
}
/**
* Find the Y position of an object, relative to the viewport
* Code copied from quirksmode.org
* @param obj Object to find y position for
*/
function findPosY(obj)
{
var curtop = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
return curtop;
}
* Find the X position of an object, relative to the viewport
* Code copied from quirksmode.org
* @param obj Object to find x position for
*/
function findPosX(obj)
{
var curleft = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curleft += obj.offsetLeft
obj = obj.offsetParent;
}
}
else if (obj.x)
curleft += obj.x;
return curleft;
}
/**
* Find the Y position of an object, relative to the viewport
* Code copied from quirksmode.org
* @param obj Object to find y position for
*/
function findPosY(obj)
{
var curtop = 0;
if (obj.offsetParent)
{
while (obj.offsetParent)
{
curtop += obj.offsetTop
obj = obj.offsetParent;
}
}
else if (obj.y)
curtop += obj.y;
return curtop;
}
相關(guān)文章
Javascript開發(fā)之三數(shù)組對象實例介紹
Javascript開發(fā)之三組數(shù)對象詳細(xì)介紹,需要的朋友可以參考下2012-11-11javascript 中__proto__和prototype詳解
本文詳細(xì)介紹了javascript的內(nèi)部原型__proto__和構(gòu)造器原型prototype,以及他們之間的異同,十分的詳盡,有需要的小伙伴快來研究下吧。2014-11-11JavaScript中Function()函數(shù)的使用教程
這篇文章主要介紹了JavaScipt中Function()函數(shù)的使用教程,是JavaScipt入門學(xué)習(xí)中的基礎(chǔ)知識,需要的朋友可以參考下2015-06-06javascript scrollLeft,scrollWidth,clientWidth,offsetWidth 完全
javascript scrollLeft,scrollWidth,clientWidth,offsetWidth 完全詳解,實例修正版。2009-07-07Javascript中 關(guān)于prototype屬性實現(xiàn)繼承的原理圖
Javascript中關(guān)于prototype屬性實現(xiàn)繼承的原理圖2013-04-04關(guān)于JavaScript的Array數(shù)組方法詳解
這篇文章主要介紹了關(guān)于JavaScript的Array數(shù)組方法詳解,數(shù)組是一個固定長度的存儲相同數(shù)據(jù)類型的數(shù)據(jù)結(jié)構(gòu),數(shù)組中的元素被存儲在一段連續(xù)的內(nèi)存空間中,它是最簡單的數(shù)據(jù)結(jié)構(gòu)之一,需要的朋友可以參考下2023-05-05