Code:findPosX 和 findPosY
* 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開(kāi)發(fā)之三數(shù)組對(duì)象實(shí)例介紹
Javascript開(kāi)發(fā)之三組數(shù)對(duì)象詳細(xì)介紹,需要的朋友可以參考下2012-11-11JavaScript window.location對(duì)象
這篇文章主要介紹了JavaScript window.location對(duì)象的相關(guān)資料,需要的朋友可以參考下2014-11-11javascript 中__proto__和prototype詳解
本文詳細(xì)介紹了javascript的內(nèi)部原型__proto__和構(gòu)造器原型prototype,以及他們之間的異同,十分的詳盡,有需要的小伙伴快來(lái)研究下吧。2014-11-11JavaScript中Function()函數(shù)的使用教程
這篇文章主要介紹了JavaScipt中Function()函數(shù)的使用教程,是JavaScipt入門(mén)學(xué)習(xí)中的基礎(chǔ)知識(shí),需要的朋友可以參考下2015-06-06javascript scrollLeft,scrollWidth,clientWidth,offsetWidth 完全
javascript scrollLeft,scrollWidth,clientWidth,offsetWidth 完全詳解,實(shí)例修正版。2009-07-07Javascript中 關(guān)于prototype屬性實(shí)現(xiàn)繼承的原理圖
Javascript中關(guān)于prototype屬性實(shí)現(xiàn)繼承的原理圖2013-04-04JavaScript 基礎(chǔ)知識(shí) 被自己遺忘的
JavaScript 基礎(chǔ)知識(shí) 被自己遺忘的,學(xué)習(xí)的朋友可以參考下。2009-10-10關(guān)于JavaScript的Array數(shù)組方法詳解
這篇文章主要介紹了關(guān)于JavaScript的Array數(shù)組方法詳解,數(shù)組是一個(gè)固定長(zhǎng)度的存儲(chǔ)相同數(shù)據(jù)類型的數(shù)據(jù)結(jié)構(gòu),數(shù)組中的元素被存儲(chǔ)在一段連續(xù)的內(nèi)存空間中,它是最簡(jiǎn)單的數(shù)據(jù)結(jié)構(gòu)之一,需要的朋友可以參考下2023-05-05