nari447
nari447

Reputation: 914

$(window).height() is giving same value as $(document).height()

as I found on web $(window).height() gives unit less pixel value of browser view-port height and, $(document).height() gives unit less pixel value of actual document height

and if document height is less than window height then $(document).height() will result in window height..

in my case I have a document which is 36px of height..

when I check $(window).height(), $(document).height() are giving same result as 36..

can someone explain what's wrong with my browser..?

Upvotes: 1

Views: 294

Answers (2)

Nithesh Narayanan
Nithesh Narayanan

Reputation: 11755

$(window).height() Gives the height ofthe browser window in which you are opened the page only the viewable portion.

where as

$(document).height() gives the height of your document. ie page

so $(window).height() may smaller than the document being rendered or may be same depending on the document. Hence in your case both will be same

Upvotes: 0

achudars
achudars

Reputation: 1506

Nothing is wrong with your browser.

The document might be larger than the window that you can visibly see (the actual stuff that can fit within the premises of your monitor).

If the resolution of your monitor is 1024 x 768, but the actual document is taller in size, let's say 4000px, then the output value of $(window).height() will be 768px while $(document).height() will be 4000px, despite the fact that at each moment you can only see 768px (in fact, you will see less, because you need to take into account that browser takes up space as well)

Your largest element is 36px in height, so both the window and the document are scaled to that size, despite the fact that you might be seeing lots of white space below.

Upvotes: 1

Related Questions