Created
August 3, 2010 01:01
-
-
Save huacnlee/505621 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 取得对向的大小和坐标 兼容多种浏览器 | |
* @param {Object} owner | |
*/ | |
var getPos = function(owner){ | |
if(owner == undefined){ | |
return {top : 0, left:0 , width : 0, height : 0}; | |
} | |
var e = owner; | |
var oTop = e.offsetTop; | |
var oLeft = e.offsetLeft; | |
var oWidth = e.offsetWidth; | |
var oHeight = e.offsetHeight; | |
while(e = e.offsetParent) | |
{ | |
oTop += e.offsetTop; | |
oLeft += e.offsetLeft; | |
} | |
return { | |
top : oTop, | |
left : oLeft, | |
width : oWidth, | |
height : oHeight | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment