- From: Anne van Kesteren <annevk@opera.com>
- Date: Wed, 23 Apr 2008 11:03:03 +0200
- To: "Daniel Glazman" <daniel.glazman@disruptive-innovations.com>
- Cc: "www-style@w3.org" <www-style@w3.org>
On Wed, 23 Apr 2008 10:52:54 +0200, Daniel Glazman <daniel.glazman@disruptive-innovations.com> wrote: > Anne van Kesteren wrote: > >> document.body.getBoundingClientRect().top - >> document.documentElement.getBoundingClientRect().top >> or >> document.body.offsetTop - document.documentElement.offsetTop > > Excerpt from your own spec : "If A is the HTML body element or does not > have an associated CSS layout box return zero and stop this algorithm". I'm sorry. I'm still a bit sleepy I guess. > So document.body.offsetTop is always zero and your last proposal above > does not work. > > If only the first one is available, that means that for all elements > but document.body, we use A.offsetTop and for document.body, we use > A.getBoundingClientRect().top ??? That's really inconsistent and > painful. Actually, you would probably always use getBoundingClientRect() as that's far more consistent and reliable than any of the offset* attributes. They are mainly defined because lots of legacy scripts use them currently to calculate the position of an element using while loops (which the specification handles fine). -- Anne van Kesteren <http://annevankesteren.nl/> <http://www.opera.com/>
Received on Wednesday, 23 April 2008 09:03:24 UTC