1. #1

    Default Answered: how to prevent <a> from opening a new safari window

    Answered: how to prevent <a> from opening a new safari window


    Hi,


    We've built a Sencha Touch application to complement our company's existing web application.


    We wanted to give the user the ability to switch between the Sencha app and the full version of our Web application.


    To do this we've simply added a button in the application labelled "View full site" that calls the following function:


    var view_full_site = function()
    {
    // redirects the user to mobile_to_full_helper which sets a "nomobile" cookie, then forwards to index.php
    window.location.href = '../includes/mobile_to_full_helper.php';
    }

    This works great and if a user has saved the Sencha app to their desktop it will open the full version of the site within the same "application window" as the mobile. (by application window I mean the window that is spawned when a user clicks on the desktop icon they have saved the sencha touch url to)


    The problem we are having occurrs when the user switches back to the full version of the application.


    On the full version of the site we have a bar across the top which displays a link: "View our mobile site". This is simply an anchor tag: <a href="../full_to_mobile.php"></a>. This clears the nomobile cookie and redirect to our sencha app (mobile.php in our case).


    BUT, when the user clicks on the "View our mobile site" on the iPhone it redirects to the iPhone version, but when doing so it opens as a new window in safari instead of in the same "application window".


    This leaves the user with two windows, the original "application window" with the full version of the site showing and a new safari window with the mobile version showing.


    We want the mobile app to just replace the existing application window rather than opening up a new Safari window. There is no target="_blank" in our <a> tag so we're perplexed as to why it behaving like this.


    Is there any way to fix this?


    Should we change the anchor link to a javascript redirect? This seems a bit silly but maybe it would work?


    Thanks for any advice!

  2. What you are bumping into is just the way that the iPhone handles url's. When a web app has been opened from the home screen it will redirect all url's to the browser ( You MUST use javascript if you want to stay in your little sandbox). Why? That's the way the Apple Gods made it (no web w/o status bar, etx).. I would suggest forgoing the whole boondoggle and using a browser sniff/ url redirect instead. It's cleaner.

  3. #2
    Sencha User
    Join Date
    Sep 2011
    Posts
    13
    Vote Rating
    1
    Answers
    1
    hugesuccess is on a distinguished road

      0  

    Default It's not Sencha, it's the Iphone being creepster.

    It's not Sencha, it's the Iphone being creepster.


    What you are bumping into is just the way that the iPhone handles url's. When a web app has been opened from the home screen it will redirect all url's to the browser ( You MUST use javascript if you want to stay in your little sandbox). Why? That's the way the Apple Gods made it (no web w/o status bar, etx).. I would suggest forgoing the whole boondoggle and using a browser sniff/ url redirect instead. It's cleaner.

  4. #3

    Default


    Hi HugeSuccess,

    Thanks for your response. That makes sense, I figured it must be something like that.

    Easy to fix.

    Cheers

Thread Participants: 1

Tags for this Thread