related to browser window's upper left corner of client area.
Asked
Active
Viewed 1,180 times
5
-
My mistake on the duplicate flag. Thought I saw a jQuery tag. – Crescent Fresh Sep 07 '09 at 14:13
1 Answers
4

Ariel Popovsky
- 4,787
- 2
- 28
- 30
-
1That's the right idea, but I believe there are some browser inconsistencies in the way `element.offsetParent` and `element.offsetTop`/`element.offsetLeft` is handled. I'd research how the major frameworks the doing this before copy/pasting that code... – Øystein Riiser Gundersen Sep 07 '09 at 14:41
-
1Actually quirksmode has been dealing with cross browser compatibility for years but if you can use Jquery (or part of it) take a look at the offset method http://docs.jquery.com/CSS/offset – Ariel Popovsky Sep 07 '09 at 15:25
-
2Indeed. The jQuery implementation is pretty hairy: http://code.google.com/p/jqueryjs/source/browse/trunk/jquery/src/offset.js Prototype's `Element.viewportOffset()` may be worth looking at as well http://prototypejs.org/assets/2009/8/31/prototype.js – Øystein Riiser Gundersen Sep 07 '09 at 18:41