如何在同一窗口中加载 iOS webclip 链接?
加载包含一些链接的 Webclip 后,单击链接会启动 Mobile Safari,而不是在同一窗口中加载链接。有没有办法阻止在 Safari 而不是 Webclip 实例中加载链接?我正在尝试在本地 Apache 安装上使用 PHP 来模拟移动应用程序。
After loading up a Webclip with some links in it, clicking a link launches Mobile Safari instead of loading the link in the same window. Is there a way to prevent the link loading in Safari instead of the Webclip instance? I'm trying to mock up a mobile app just using PHP on my local Apache installation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据 Apple 文档,它看起来像外部页面链接将始终在 Mobile Safari 中打开:
According to the Apple docs it looks like external page links will always open in Mobile Safari:
除了使用 AJAX 的单页加载新内容的选项之外,您还可以使用 JavaScript
self.location=URL;对于必须保留在应用程序内的超链接返回 false
。这可以直接添加到 HTML 代码中,或者在加载页面时使用另一个脚本添加到 HTML 代码中。如果您使用 jQuery,我会推荐这样的内容:
显然,这个脚本应该在 HTML 加载后运行,以确保它实际上附加到
A
元素onClick
事件。In addition to the option of using a single page loading new content with AJAX, you can use the JavaScript
self.location=URL; return false
on hyperlinks that must stay within the application. This can be added to the HTML code directly, or with another script upon loading the page.If you are using jQuery, I would recommend something like this:
Obviously this script should be ran after the HTML has loaded, to ensure that it actually attaches to the
A
elementsonClick
event.