window.scrollTo(0, 1) not working on page refresh?

2,893 views
Skip to first unread message

.:: Pe16::.

unread,
Sep 6, 2010, 5:18:18 AM9/6/10
to iPhoneWebDev
Hy,

(tested on ipod)
When opening my webapp in safari mobile, the URL bar can be hidden
with the window.scrollTo(0, 1) method (wich seems to be the officially
documented way for hiding the iPhone toolbar..)

That works!

But if you then, touch the statusbar (top) the URL bar is unveiled.
Now you would think that you sould just refresh the page (refresh
arrow at the end of the URL in URL bar) and hide the URL bar...but
that doesn't seems to work.

However, if you instead of clicking the refresh arrow, just hit the
"Go" button on the iphone keyboard -> the method works and URL bar is
hidden (window.scrollTo(..))

So this means probably that page_refresh is not opening the page as if
you go twice to the same page. Maybe it's from a cache..?

I'v tried to wait the page completes rendering and then do
scrollTo..but nothing.

Have you seen this/figured it out?


ps.

This is tested on ipod when you open your webapp from safari (not
first added at homescreen)

I know there are some meta tags that work if you open your webapp from
the homescreen..this is not where the problem is. It is exlusively in
mobile safari


.:: Pe16::.

unread,
Sep 6, 2010, 6:40:27 AM9/6/10
to iPhoneWebDev
Due to some progress need to modify this one.

I have managed the refresh problem, just need to delay it a little
bit:

window.onload = function() {
setTimeout(function(){window.scrollTo(0, 1);}, 100);
}

That's fine. The problem is that this method won't work on a
"touchscroll" (http://github.com/davidaurelio/TouchScroll ) enabled
page.

So if anyone is using touchscroll framework in his projekt and have
sorted out the url hiding please let me know.

thx

Touchscroll

Giacomo Balli

unread,
Sep 6, 2010, 7:57:10 AM9/6/10
to iPhoneWebDev
touching the status bar simply scrolls all the way up. It is made to
show the URL bar.
Refresh arrow refreshes the page. If there are no changes it doesn't
"change".
The go button "opens" the url inserted therefore actually fetches and
displays the page.
I doubt you would be able to hide the url bar since Apple wants to
provide a way of doing so.
Unless you set a timer/interval that check the current display and in
case (if the user didn't already scroll down) make sure that it's at
(0,1).

On Sep 6, 11:18 am, ".:: Pe16::." <pet...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages