0

I need to assess the total height of a document on the fly, along with the window height and scroll in order to position a moving element accurately.

The trouble I am having is that $(document).height() seems to be sending me the wrong figure.

On the page refresh, the document reports one figure, but after resizing the window, and putting it back as it was, that figure has changed by over 200px!!

Any known issues that could cause this?

Mild Fuzz
  • 29,463
  • 31
  • 100
  • 148

1 Answers1

2

According to comments here, $( document ).height() is unreliable. You may have better results using $( window ).height().

Community
  • 1
  • 1
George Cummins
  • 28,485
  • 8
  • 71
  • 90
  • I do get more accurate results from that. The problem is that I am trying to find a way of making sure that an element that is being animated does not move over the element it is supposed to be pointing at. I am using `$(window).height() + $(window).scrollTop()` and comparing that figure with `$(document).height()` to establish how far from the base of the document my fixed position element is. – Mild Fuzz Jun 22 '11 at 07:45