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!
If you use jQuery you could do:
$(document).scrollTop();
http://api.jquery.com/scrollTop/
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.
精彩评论