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基礎(chǔ)教程之定義和調(diào)用函數(shù)
這篇文章主要介紹了Javascript基礎(chǔ)教程之定義和調(diào)用函數(shù)的相關(guān)資料,需要的朋友可以參考下2015-01-01
javascript Window及document對象詳細(xì)整理
注:頁面上元素name屬性以及JavaScript引用的名稱必須一致包括大小寫否則會提示你1個錯誤信息 引用的元素為空或者不是對象2011-01-01
javascript 構(gòu)造函數(shù)方式定義對象
這篇文章主要介紹了javascript 構(gòu)造函數(shù)方式定義對象的方法及示例,需要的朋友可以參考下2015-01-01
script標(biāo)簽的 charset 屬性使用說明
如果外部文件中的字符編碼與主文件中的編碼方式不同,就要用到 charset 屬性。2010-12-12

