10

I've developed a web app for the iPhone, and I have it bookmarked and added to my iPhone's home screen. I'm noticing a problem with it, though: it works as intended until I navigate to a page within the app that has a query string and parameters - for example, www.mywebapp.com/page02.html?param1=value&param2=value2 . When I go to a page with such a URL, iOS switches me from the embedded version of Safari to the main Safari app - it takes me out of my app. I don't know why this is happening.

What causes this and what can I do about it?

Brighid McDonnell
  • 4,293
  • 4
  • 36
  • 61
user1094000
  • 197
  • 3
  • 6
  • What do you mean "switches from the home-screen to Safari"? Does the bookmarked app disappear from the homescreen - or does it switch from a UIWebView-style browser over to Mobile Safari? – Brighid McDonnell Dec 12 '11 at 17:22
  • Hi! With "switches..." I mean that the WebApp switches from a UIWebView-style browser over to Mobile Safari as you mentioned. It is strange because it only happens when I use parameters in the URL. I suppose that there will be some restrictions with iphone webapps and url parameters. Do you know any solution for this issue? – user1094000 Dec 12 '11 at 19:00
  • Possible duplicate of [iPhone Safari Web App opens links in new window](http://stackoverflow.com/questions/2898740/iphone-safari-web-app-opens-links-in-new-window) – nkron Nov 21 '15 at 20:14

4 Answers4

8

Many thanks to @BjornKaiser who provided the solution, here is a simple jQuery script that will handle this for you for all links.

Add this to the head section of your master ASP.Net page. Make sure you have jquery included:

<head>
    <!-- Your reference to your jQuery library -->
    <script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>

    <script type="text/javascript">
        $(function() {
          $('a').click(function() {
            document.location = $(this).attr('href');
            return false;
          });
        });
    </script>
</head>
Simon Epskamp
  • 8,813
  • 3
  • 53
  • 58
5

That's the way Apple designed it. If you need a multi-view Web App you need to implement the page switching logic in JavaScript. Everything else will cause the problem you described -> jumping to Safari.

Björn Kaiser
  • 9,882
  • 4
  • 37
  • 57
0

I'm not sure what causes this, but this question about UIWebView issues has a solution for how to make some links open in the UIWebView page and some open in Mobile Safari, so I bet you could generalize from that to a solution to your problem.

Community
  • 1
  • 1
Brighid McDonnell
  • 4,293
  • 4
  • 36
  • 61
-1

I found the best solution: using client-side data storage. You can use JavaScript to store variables information into the variables localStorage and sessionStorage.

Look at these links: O'Reilly client-side data storage tutorial and Apple key-value client-side data storage tutorial for web apps

user1094000
  • 197
  • 3
  • 6