Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #13299

Re: Finding the V offset of an element

From Hans-Georg Michna <hans-georgNoEmailPlease@michna.com>
Newsgroups comp.lang.javascript
Subject Re: Finding the V offset of an element
Date 2012-04-08 18:27 +0200
Organization albasani.net
Message-ID <m1f3o7dk2qnrpsdnal9juf7tmkhmuubds6@4ax.com> (permalink)
References <jlgbcm$eti$1@dont-email.me> <915c3423-61a2-41ef-b6e1-6ade73c4911f@j14g2000vbc.googlegroups.com> <9lhqn7t00esaoni3tepmmieshv5k8se165@4ax.com> <DPSdnYbaVMh0xODSnZ2dnUVZ8iydnZ2d@giganews.com>

Show all headers | View raw


On Thu, 5 Apr 2012 09:38:04 +0100, Richard Cornford wrote:

>Hans-Georg Michna wrote:

>> On Wed, 4 Apr 2012 04:57:56 -0700 (PDT), Richard Cornford wrote:

>>> There are no reliable general methods (and the ones that get
>>> closest to being general are quite complex), but given any
>>> real-world context the odds are that a safe and clean method
>>> can be created to do the job.

>> So the following would not work reliably?
>>
>> function absTop(el) {
>>  var t = 0;
>>  do t += el.offsetTop;
>>  while (el = el.offsetParent);
>>  return t;
>> }

>For some values of "reliable", yes. It certainly is not a general 
>solution for providing an accurate value for the total pixel offset of 
>an element within a displayed document in all contexts. There are other 
>factors that this will not take account for. For example; the possible 
>non-zero (top/left) border widths of any element within the chain of - 
>offsetParent -s. The - offsetTop/Left - is the offset from the inside of 
>the containing element to the top/left pixel of the contained element, 
>where the inside is within any borders and the top/left pixel is the 
>top/left of any border. However, there are contexts where none of the 
>elements in the - offsetParent -s chain have borders, padding or 
>margins, where that code might be entirely suitable.

Thanks! So does anybody here know of any published routine that
generally solves this problem at least for most not too old
browsers? How about My Library?

Hans-Georg

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Finding the V offset of an element "Leonardo Azpurua" <leonardo@exmvps.org> - 2012-04-03 21:54 -0430
  Re: Finding the V offset of an element "Leonardo Azpurua" <leonardo@exmvps.org> - 2012-04-03 22:18 -0430
    Re: Finding the V offset of an element "Leonardo Azpurua" <leonardo@exmvps.org> - 2012-04-03 22:34 -0430
    Re: Finding the V offset of an element Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> - 2012-04-04 14:49 +0200
      Re: Finding the V offset of an element "Leonardo Azpurua" <leonardo@exmvps.org> - 2012-04-04 10:28 -0430
        Re: Finding the V offset of an element Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> - 2012-04-05 09:12 +0200
      Re: Finding the V offset of an element Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2012-04-04 20:28 +0200
        Re: Finding the V offset of an element Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> - 2012-04-05 09:13 +0200
      Re: Finding the V offset of an element Richard Cornford <Richard@litotes.demon.co.uk> - 2012-04-04 07:05 -0700
        Re: Finding the V offset of an element Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-04-04 22:28 +0200
          Re: Finding the V offset of an element Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2012-04-05 00:44 +0200
            Re: Finding the V offset of an element Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-04-05 05:50 +0200
              Re: Finding the V offset of an element Eric Bednarz <bednarz@fahr-zur-hoelle.org> - 2012-04-05 11:22 +0200
                Re: Finding the V offset of an element Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-04-05 13:21 +0200
          Re: Finding the V offset of an element Richard Cornford <Richard@litotes.demon.co.uk> - 2012-04-05 04:35 -0700
            Re: Finding the V offset of an element Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-04-05 14:02 +0200
              Re: Finding the V offset of an element Richard Cornford <Richard@litotes.demon.co.uk> - 2012-04-10 09:32 -0700
          Re: Finding the V offset of an element John G Harris <john@nospam.demon.co.uk> - 2012-04-05 14:54 +0100
            Re: Finding the V offset of an element Gene Wirchenko <genew@ocis.net> - 2012-04-05 08:37 -0700
  Re: Finding the V offset of an element Richard Cornford <Richard@litotes.demon.co.uk> - 2012-04-04 04:57 -0700
    Re: Finding the V offset of an element Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> - 2012-04-05 09:16 +0200
      Re: Finding the V offset of an element "Richard Cornford" <Richard@litotes.demon.co.uk> - 2012-04-05 09:38 +0100
        Re: Finding the V offset of an element Hans-Georg Michna <hans-georgNoEmailPlease@michna.com> - 2012-04-08 18:27 +0200
  Re: Finding the V offset of an element Dr J R Stockton <reply1214@merlyn.demon.co.uk.not.invalid> - 2012-04-06 21:52 +0100
    Re: Finding the V offset of an element "Leonardo Azpurua" <leonardo@exmvps.org> - 2012-04-07 11:18 -0430

csiph-web