Skip to content

Instantly share code, notes, and snippets.

@davglass
Created January 25, 2009 04:24
Show Gist options
  • Select an option

  • Save davglass/51683 to your computer and use it in GitHub Desktop.

Select an option

Save davglass/51683 to your computer and use it in GitHub Desktop.
function getPosition(el) {
if (el.getBoundingClientRect) {
//They have getBoundingClientRect
var box = el.getBoundingClientRect();
if (typeof arguments.callee.offset != "number") {
var temp = document.createElement("div");
temp.style.cssText = "position:absolute;top:0;left:0";
document.body.appendChild(temp);
arguments.callee.offset = -temp.getBoundingClientRect().top;
document.body.removeChild(temp);
temp = null;
}
} else {
//Other Browsers here..
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment