views:

100

answers:

2

I'm programming a Webpage/-Application for the iPhone. I need to scroll to a specific position after page reload, no matter where I scrolled to while using the page before. The script I use works fine in firefox but not in mobileSafari. In corntrast to firefox, mobileSafari seems to save the position I scrolled to previously and jumps there after reload, ignoring my scrollTo triggered on reload.

This is the code I use:

function scroller(){scrollTo(1000,1000);}
window.addEventListener("load",scroller, false);

It works with click-events that I trigger manually. If I click a button than the scrolling is done. I tried to trigger the click via a synthetic event javascript, but this does not work either.

Is there any way the scrolling can be archived on reload and/or other not explicitly user triggered events?

A: 

I did not find a solution for the actual problem which seems to be a bug. But I found a workaround. This is not to trigger the scrolling directly via an onload event but to use a setTimeout()

init(){
setTimeout(scrollTo(0, 1000), 10)
//more code
}
//more code
window.onload=init;
JanD
A: 

What about the iscroll prototype !?

Alexandre