2

I'm making my first mobile app, and have a weird issue. When the app is launched regularly through safari, obviously the links work as if any other regular HTML links. When I add the webapp to my home screen (to get the full effect, button, splash, and get rid of the safari controls) then I have a problem where whenever a link is clicked it closes the webapp and relaunches in normal safari.

dave
  • 123
  • 1
  • 2
  • 8

2 Answers2

2

That's exactly how links work. It has nothing to do with iScroll. If you want to stay within the web app, you need to load the pages with Ajax instead.

Since you're developing for a mobile browser, you probably don't have to worry much about Ajax compatibility; you can use XMLHttpRequest to load your pages.

Ry-
  • 218,210
  • 55
  • 464
  • 476
  • @dave: Here's a tutorial I found: http://www.tizag.com/ajaxTutorial/ You can also just have a look around Google, search "Ajax page loading" or "Ajax tutorials" and you'll get lots of results. – Ry- Nov 24 '11 at 04:17
0

I also found this solution (sorry, i couldn't find url of the original post)

var a=document.getElementsByTagName("a");
for(var i=0;i<a.length;i++)
{
    a[i].onclick=function()
    {
        window.location=this.getAttribute("href");
        return false
    }
}

...this "hack" works for me. Hope it helps!

JakubKnejzlik
  • 6,363
  • 3
  • 40
  • 41