Reputation: 20348
I want to know the height of the current view port or screen which is currently shown. That means if some of the part of the page is not shown due to overflowing, it should not include that.
All of the following gave me same result, which includes the scrolling/non visible area of the page -
$(document).height();
$(windows).height();
document.body.clientHeight;
Can someone please let me know how can I know the height of the currently visible area of document in either JS or jQuery?
Upvotes: 0
Views: 221
Reputation: 6517
I don't get your problem. $(window).height()
should return the height of the viewport excluding anything which requires you to scroll. If you take a look into the Documentation, you'll read:
// Returns height of browser viewport
$( window ).height();
// Returns height of HTML document
$( document ).height();
An alternative is using window.innerHeight
. But this returns the same as $(window).height()
for me.
For getting the height of the screen, you can use screen.height
(screen object). This will return the height of the entire screen (including the browsers's top bar and the windows taskbar). screen.availHeight
in contrast includes only the browser's top bar.
Upvotes: 1