如何在 iOS 7 中从 WebApp 打开 Safari [英] How to open Safari from a WebApp in iOS 7

查看:43
本文介绍了如何在 iOS 7 中从 WebApp 打开 Safari的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以前的 iOS 版本中,<a> 标签会打开 Mobile Safari,您必须拦截它们才能留在 web 应用程序(已保存到主屏幕的 HTML 页面)中由用户).

In previous versions of iOS, <a> tags would open Mobile Safari, and you had to intercept those to instead stay inside the webapp (an HTML page that has been saved to the home screen by the user).

从 iOS 7 开始,所有链接都保留在 WebApp 内.我不知道如何让它在我真正想要的时候打开 Safari.

Starting in iOS 7, all links are staying inside the WebApp. I cannot figure out how to get it to open Safari, when I really want it to.

我尝试过使用 window.opena target="_blank" 但都没有效果.

I've tried using window.open and a target="_blank" but neither works.

这是一个示例.https://s3.amazonaws.com/kaontest/testopen/index.html

如果您在 iOS 6 中将其保存到主屏幕,则该链接将打开 Safari.但在 iOS 7 中,它没有.

If you save that to your home screen in iOS 6, the link opens Safari. But in iOS 7, it doesn't.

请注意,这是每个人通常都会问的相反问题(如何不打开 Safari").这种行为似乎是新的默认行为,我不知道如何恢复旧行为!

Note that this is the OPPOSITE question that everyone is usually asking ("how to NOT open Safari"). That behavior seems to be the new default, and I can't figure out how to get the old behavior back!

推荐答案

使用带有目标 _blank 的锚标记将在 iOS 7.0.3 中工作,但使用 window.open 将不起作用,并将继续在 7.0.3 中的 webview 中打开:

Having an anchor tag with target _blankwill work in iOS 7.0.3 but using window.open will not work and will remain to open within the webview in 7.0.3:

window.open('http://www.google.com/', '_blank');

这篇关于如何在 iOS 7 中从 WebApp 打开 Safari的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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