Window height vs. document height


i get a totally different value when i use the height jquery method.

I know it should be slightly different but the window gives me a value of 297 and the document is at 1173.

why there is such a difference?

 var documentHeight = $(document).height();

 var windowHeight = $(window).height();

It’s because the height of the content on your page is much larger than the viewport height. But though I realise that there is some issue there, it’s not possible to say what that issue is without seeing the full structure (CSS and HTML)

that’s weird. I am writing some code on a test page i have locally on my computer. maybe because it is local it shows such a gap? does the viewport height change according to the content?

No, it should return the height of the window you are viewing it in (so, the viewport). It is the document height that is dependent on content.