views:

594

answers:

1

Is there a way to determine the position of the "viewport" in mobile safari on a web page? Like x, y, w, h pixel positions of what the phone is currently seeing on the page?

+1  A: 

In javascript (on Mobile Safari) you can use window.pageXOffset and window.pageYOffset to get the x and y offsets, window.innerWidth and window.innerHeight to get w and h.

Jeethu
This fails if you reload the page and the page is already scrolled down. Reports "0".
Typeoneerror
@typeoneerror: I got a similar problem with the "already scrolling down": http://stackoverflow.com/questions/3654024/mobilesafari-auto-scroll-pan-to-specific-position-on-page-after-reloadPlease let me know if you find any solution for the problem.
JanD