0

I have a very strange error. I have an webpage that runs in Appmode (when you add to homescreen on iOS). I have one A element that transfer to another page in the same domain (test2.html). If I click on it, the appmode is quited and a new browser window opens.

However if I make a location.href = 'test2.html' it works. And now the strange part, on test2.html I just have one A element with href="test1.html", and now it works.

I have a thesis that every link will work in your own domain if you sometime have done a location.href before clicking any other link.

My test case:

Test2.html

        <a href="javascript:void();" onclick="transfer();">Test1</a>
        <script>
        function transfer(){
            location.href = "test1.html";
        }
        </script>

Test1.html

        <a href="test2.html">Test2</a>

You can change Test2 so it similar to Test1 and just change the href and it will broke.

I really have no ide why this is happening. Why does it work just after you have done a location.href in the same domain?

Simon Edström
  • 6,461
  • 7
  • 32
  • 52

1 Answers1

1

I've had exactly the same problem. For now, I solved it simply by making my link return false:

<a href='#' onclick='doSomething(); return false;'>test</a>

EDIT: This seems like a better answer: iPhone Safari Web App opens links in new window

Community
  • 1
  • 1
Jelmer
  • 61
  • 4