Skip to content

Instantly share code, notes, and snippets.

@hotoo
Created August 29, 2011 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hotoo/1178528 to your computer and use it in GitHub Desktop.
Save hotoo/1178528 to your computer and use it in GitHub Desktop.
javascript:(function(id){
var getOffset = function(z) {
var x=0, y=0;
while (z) {
x += z.offsetLeft;
y += z.offsetTop;
z = z.offsetParent;
}
return [x, y];
};
var elem = document.getElementById(id);
alert(getOffset(elem));
})("container");void(0);
javascript:(function(id){var getOffset=function(z){var x=0,y=0;while(z){x+=z.offsetLeft;y+=z.offsetTop;z=z.offsetParent;}return [x,y];};var elem=document.getElementById(id);alert(getOffset(elem));})("container");void(0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment