可以打开 iPhone Safari 并定位特定窗口吗?

发布于 2024-08-09 16:51:22 字数 503 浏览 6 评论 0原文

我有一个使用 OAuth 进行身份验证的应用程序,这意味着必须将用户定向到网站才能授权该应用程序。我更喜欢让用户清楚地知道他们正在使用标准浏览器在原始站点上进行授权,而不是仅仅使用 Web 视图来显示我的应用程序中的内容。然而,每次他们被定向到 Safari(通过 openURL)时,它都会启动一个新的 Safari 窗口,一旦 Safari 打开 8 个窗口,它就根本无法工作。

我想知道 html 中是否存在与锚标记的“目标”属性等效的属性,它允许我使应用程序中的所有 openURL 调用在同一窗口中打开。

我还可以通过 Web 应用程序公开其他功能,在 Safari 中创建本机 iPhone 功能和 Web 应用程序功能之间的混合应用程序,但如果我每次在应用程序和 Safari 之间切换时都必须启动一个新窗口,那么它就变得不可行。 Youtube 应用程序显然能够在显示视频后将用户返回到上一页,但这很可能是 iPhone Safari 中的自定义插件。此外,虽然返回到上一页有些用处,但将它们发送到现有窗口中的新 URL 确实带来了很多可能性。

I have an app that uses OAuth to authenticate, which means the user must be directed to the website to authorize the application. I prefer to make it obvious to the user that they are using a standard browser to authorize at the original site rather than just using a web view to show the content within my app. However, every time they are directed to Safari (via openURL), it launches a new Safari window and once Safari has 8 windows open, it simply fails to work at all.

I'm wondering if there is an equivalen to the "target" attribute of an anchor tag in html which would allow me to cause all openURL calls from my application to open in the same window.

There is other functionality that I can expose via the web application, creating a hybrid app between native iphone functionality and web app functionality in Safari, but if I have to launch a new window every time I switch between the app and Safari, it becomes unworkable. The Youtube app is obviously able to return the user to the previous page after showing a video, but that might well be a custom plugin in Safari for iphone. Also, while returning to the previous page is somewhat useful, sending them to a new URL in the existing window really opens up a lot of possiblities.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

水染的天色ゝ 2024-08-16 16:51:22

我很确定没有办法将目标参数传递给 openURL:

我对 Safari 的注意到是,如果您使用 openURL: 打开的页面已经在 Safari 中打开,它就不会打开另一个选项卡。它只是重新加载该页面。这可能听起来微不足道且没有帮助,但如果您可以使您的 Web 应用程序仅使用一页,也许您可​​以利用它来发挥您的优势。不同的视图或状态可以用#anchor标签来表达。

例如 http://m.flickr.com。注意到他们的 URL 结构了吗?它是http://m.flickr.com/#/homehttp://m.flickr.com/#/explore/interesting/http://m.flickr.com/#/search 等等。对于用户来说,所有这些都是不同的网页,但对于 Safari 来说,它们都是相同的页面。

I'm pretty sure there is no way to pass a target parameter to openURL:.

What I noticed about Safari is that it won't open another tab if the page you are opening with openURL: is/was already open in Safari. It just reloads that page. This might sound trivial and not helpful but perhaps you could use it to your advantage if you can make your web application only use one page. Different views or states could be expressed with #anchor tags.

An example is http://m.flickr.com. Notice their URL structure? It goes http://m.flickr.com/#/home, http://m.flickr.com/#/explore/interesting/, http://m.flickr.com/#/search and so on. All of these are different web pages to the user but to Safari it's all the same page.

不疑不惑不回忆 2024-08-16 16:51:22

我发现 iOS 6.0.1 Safari 会使用简单的主题标签(不带斜杠)打开相同的选项卡。因此,在上面的示例 http://m.flickr.com 中,openURL 为 http://m.flickr.com#someinfo 打开同一选项卡。

在您的网页中,使用 window.location.hash 返回参数。在上面的示例中它将返回#someinfo。

I found iOS 6.0.1 Safari will open the same tab with a simple hashtag, without the slashes. So with the above example http://m.flickr.com, openURL to http://m.flickr.com#someinfo opens to the same tab.

In your webpage, use window.location.hash to return the params. In the above example it will return #someinfo.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文