Prevent iOS web app w/ redirect from opening link in mobile Safari

萝らか妹 提交于 2019-12-11 14:01:32

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!