How to find (in javascript) the current "scroll" offset in mobile safari / iphone

Posted by mintywalker on Stack Overflow See other posts from Stack Overflow or by mintywalker
Published on 2010-03-24T10:44:28Z Indexed on 2010/03/24 20:23 UTC
Read the original article Hit count: 669

Filed under:
|
|
|

I'd like to know the x/y offset of the how far the user has "scrolled" within the viewport in mobile safari on the iphone.

Put another way, if I (through javascript) reloaded the current page, I'd like to find the values I'd need to pass into window.scrollTo(...) in order to reposition the document/viewport as it is currently.

window.pageXOffset always reports 0

jquery's $('body').scrollTop() always reports 0

events have a pageX, but this won't account for the scrolling of the page that happens after you release your finger if your gesture was to "flick" the page up/down. Namely, it'll give me a point when the finger leaves the screen, but that doesn't always match where the page will be after it's finished scrolling.

Any pointers?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about mobilesafari