Pergunta

After loading up a Webclip with some links in it, clicking a link launches Mobile Safari instead of loading the link in the same window. Is there a way to prevent the link loading in Safari instead of the Webclip instance? I'm trying to mock up a mobile app just using PHP on my local Apache installation.

Foi útil?

Solução

According to the Apple docs it looks like external page links will always open in Mobile Safari:

In this mode any external links will be opened in Safari on iPhone, meaning that you will have to keep your web application to a single page and use Ajax to update parts of that page.

Outras dicas

In addition to the option of using a single page loading new content with AJAX, you can use the JavaScript self.location=URL; return false on hyperlinks that must stay within the application. This can be added to the HTML code directly, or with another script upon loading the page.

If you are using jQuery, I would recommend something like this:

$('a:not([target])').click(function(){
    self.location = $(this).attr('href');
    return false;
});

Obviously this script should be ran after the HTML has loaded, to ensure that it actually attaches to the A elements onClick event.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top