0

I was looking to find the top position of my footer. I have tried:

$('#footer').offset().top

and

$(document.body).height() - $('#footer').height()

Both of these gave me the same answer but the wrong answer. I have noticed that as I scroll past a certain point in the document the body height (as viewed in Firebug layout) changes from 5699 to 11506.

I have tried setting:

body { min-height: 100% }
head { height : 100% }

with no success.

My question is why does the body height change and how can I determine the real height of my body or document (or the top position of my footer)?

*Update: weirdly this appears to now work on my Windows >> Firefox & Chrome browsers, but is out by nearly double on my OSX >> Firefox & Chrome browsers. Any ideas?

greenafrican
  • 2,516
  • 5
  • 27
  • 38

1 Answers1

0

Continue troubleshooting:

console.log( $(document.body).height() );
console.log( $(document).height() );
console.log( $('body').height() );

See if any one these gives desired values.

I just tried them myself, and noticed different result.

$(document.body).height() > $(document).height()

So try without the .body and see what you get.

Robin Castlin
  • 10,956
  • 1
  • 28
  • 44
  • best results achieved using $('body') in Firefox. Will do testing on other browsers soon. Thank – greenafrican May 15 '12 at 09:14
  • weirdly this appears to now work on my Windows >> Firefox & Chrome browsers, but is out by nearly double on my OSX >> Firefox & Chrome browsers. Any ideas? – greenafrican May 15 '12 at 16:24
  • Keep exploring in OSX, and then do a [solution by OS](http://stackoverflow.com/questions/7044944/jquery-javascript-to-detect-os-without-a-plugin). – Robin Castlin May 15 '12 at 19:57