moey
moey

Reputation: 10897

Coordinates of Document that is Currently Visible on Browser

How do I find out the coordinates of the web page / document that is currently visible on my browser? For example, $(window).height() returns 700 and $(document).height() returns 3,000 i.e. my document is longer than the browser's height. I'd like to find out, after interacting with the page (e.g. scrolling), which area of my document is currently visible.

Thanks!

Upvotes: 1

Views: 577

Answers (2)

Jishnu A P
Jishnu A P

Reputation: 14380

You could use

window.innerHeight

Height (in pixels) of the browser window viewport including, if rendered, the horizontal scrollbar.

window.innerWidth

Width (in pixels) of the browser window viewport including, if rendered, the vertical scrollbar.

Upvotes: 0

Cristian Necula
Cristian Necula

Reputation: 1245

If you use jQuery you could do:

$(document).scrollTop();

http://api.jquery.com/scrollTop/

Upvotes: 1

Related Questions