开发者

Coordinates of Document that is Currently Visible on Browser

开发者 https://www.devze.com 2023-03-12 04:14 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消