问题
I’m currently developing a web app using HTML5, CSS3 and PHP that connects to Readmill’s API with oAuth.
I want the website to behave like a web app (“installed” on home screen) on iOS which leads to my problem: To authenticate users, my page has to redirect to Readmill’s authentication page. This works flawlessly if the user has been logged in before using mobile safari and uses cookies—hence is still logged in and just has to tap on “Allow” on the “Grant access” page.
If the user isn’t logged in, it gets redirected to the sign-up form which happens inside the app. But if it then tries to sign in by tapping on “Sign in if you already have an account” the app opens the page in mobile Safari.
The sign-up/sign-in forms are part of Readmill’s page so I cannot change how links behave—otherwise I would have tried changing its behaviour using jQuery or JavaScript.
Is there any way to keep the user inside the app all the time except for having them log in in Safari prior to opening the web app?
回答1:
Adding this code worked for me:
$('a').click(function() {
window.location.href = this.href;
return false;
});
来源:https://stackoverflow.com/questions/20091014/prevent-ios-web-app-w-redirect-from-opening-link-in-mobile-safari