0

I am trying to get document's height, so I can do comparisons about in which part of the document a particular element is.

Here is what I have found How to get documet height and width without using jquery. However, when I open that particular link, and I open the Chrome Inspect Console and type:

document.body.clientHeight

I get

2405

This is weird because if I sum up the heights of the different parts of the site (header, content, footer), it doesn't count 2405. Particularly I get:

header: 120px
content: 450px
footer: 439px

What am I missing?

Thanks

Community
  • 1
  • 1
Hommer Smith
  • 26,772
  • 56
  • 167
  • 296
  • What do the parts sum up to? – Robbie Wxyz Oct 11 '13 at 22:10
  • depends, does the content not reach the bottom of the page, or does it extend beyond the page? – zzzzBov Oct 11 '13 at 22:10
  • @SuperScript I have edited my question with the sum up I get. – Hommer Smith Oct 11 '13 at 22:15
  • @zzzzBov It is extended beyond the page. But I am trying to get the original height of the document, no matter if you are looking it with a bigger/smaller screen. I want to know what is the height of the document, so later I can figure out if a particular image is in the "upper" part or the "lower" part of the document. – Hommer Smith Oct 11 '13 at 22:16
  • I think you should make a [reduced test case on jsfiddle](http://jsfiddle.net) so that we can see the HTML that you're using that would cause this issue. I can only guess that you missed some elements, got the height incorrectly, or forgot to include margins/paddings in accessing the heights. – zzzzBov Oct 11 '13 at 22:27
  • zzzzBov I'm using the HTML of this link: http://stackoverflow.com/questions/5484578/how-to-get-document-height-and-width-without-using-jquery – Hommer Smith Oct 11 '13 at 22:28

0 Answers0