Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webapp for iphone switches from home screen to Safari when url parameters are used

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?

like image 748
user1094000 Avatar asked Dec 12 '11 15:12

user1094000


People also ask

How do I open a link in an app instead of Safari?

Go to settings, apps, then find that app on your list, click it, part way down that page there an option called opens by default, select that. How can I control which browser opens links in Android?

How do I open links directly on my iPhone app?

Opener is an app that allows you to open links from the web in apps instead! Copy a link and launch Opener to see the apps that it can be opened in, or use Opener's action extension right from other apps!

How do I change URL in Safari on iPhone?

To edit the URLs in Safari, "Touch and hold the Space bar with one finger until the keyboard turns light gray." Then, you can move the insertion point anywhere you want by dragging around the keyboard. Cheers!


2 Answers

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>
like image 163
Simon Epskamp Avatar answered Nov 15 '22 19:11

Simon Epskamp


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.

like image 42
Björn Kaiser Avatar answered Nov 15 '22 20:11

Björn Kaiser