Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@adunkman
Created July 3, 2013 14:51
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 adunkman/5918784 to your computer and use it in GitHub Desktop.
Save adunkman/5918784 to your computer and use it in GitHub Desktop.

Taken from element.getBoundingClientRect MDN documentation:

For cross-browser compatibility, use window.pageXOffset and window.pageYOffset instead of window.scrollX and window.scrollY, except use (((t = document.documentElement) || (t = document.body.parentNode)) && typeof t.ScrollLeft == 'number' ? t : document.body).ScrollLeft and (((t = document.documentElement) || (t = document.body.parentNode)) && typeof t.ScrollTop == 'number' ? t : document.body).ScrollTop when window.pageXOffset and window.pageYOffset (and window.pageXOffset and window.pageYOffset) are undefined.

Oye.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment