阻止带有重定向的iOS Web应用在移动Safari中打开链接 [英] Prevent iOS web app w/ redirect from opening link in mobile Safari

查看:458
本文介绍了阻止带有重定向的iOS Web应用在移动Safari中打开链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用HTML5,CSS3和PHP开发一个Web应用程序,该应用程序通过oAuth连接到 Readmill的API

I’m currently developing a web app using HTML5, CSS3 and PHP that connects to Readmill’s API with oAuth.

我希望网站的行为类似于iOS上的网络应用程序(安装"在主屏幕上),这导致我的问题:要对用户进行身份验证,我的页面必须重定向到Readmill的身份验证页面.如果用户已经在使用移动浏览器和Cookie之前登录过,那么此方法就可以正常工作.因此,用户仍然可以登录,只需在授予访问权限"页面上点击允许"即可.

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.

如果用户未登录,则会将其重定向到签名-表单发生在应用程序内部.但是,如果它随后尝试通过点击如果您已经有一个帐户登录"来登录 ,则该应用将在移动Safari中打开该页面.

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.

注册/登录表单是Readmill页面的一部分,因此我无法更改链接的行为-否则,我会尝试使用jQuery或JavaScript更改其行为.

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.

除了让用户在打开Web应用之前登录Safari之外,是否有其他方法可以将用户始终保持在应用内部?

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?

推荐答案

添加此代码对我有用:

$('a').click(function() {
    window.location.href = this.href;
    return false;
});

这篇关于阻止带有重定向的iOS Web应用在移动Safari中打开链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆