I am building an iphone webapp and have a page with an input field. I\'d like the field to scroll up to just above the virtual keyboard when it shows up. I\'ve tried putting
As far as I know the problem your getting is that when the keyboard launches, the browser is trying to move the window into view of the element itself.
What might be happening is that the scroll bar position is being recorded before the keyboard pops up. The browser is then calculating the distance the window needs to move to bring the element into view, once the keyboard has popped up, based on the recorded value. By which time you have changed the position of the window. So it's moving the window relative to the position you set as opposed to the position it thinks it's at.
What is behaviour are you experiencing if you don't try to scroll the element into view manually ( no scripting )?
I'm under the impression the iPhone browser natively does what you want. If not it might have something to do with element positioning. I.E. The browser can't properly calculate the position of the element e.g. If it's in a fixed position container ( because it's location is going to move as soon as the browser tries to scollTo it ).
If that fails maybe try putting the scrollTo function inside a time-out so it fires after the keyboard has come up.