如何在同一窗口中加载 iOS webclip 链接?

发布于 2024-12-25 17:47:45 字数 135 浏览 5 评论 0原文

加载包含一些链接的 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 技术交流群。

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

发布评论

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

评论(2

伤痕我心 2025-01-01 17:47:45

根据 Apple 文档,它看起来像外部页面链接将始终在 Mobile Safari 中打开:

在此模式下,任何外部链接都将在 Safari 中打开
iPhone,这意味着您必须将您的 Web 应用程序保持在
单页面并使用 Ajax 更新该页面的部分内容。

According to the Apple docs it looks like external page links will always open in Mobile Safari:

In this mode any external links will be opened in Safari on
iPhone, meaning that you will have to keep your web application to a
single page and use Ajax to update parts of that page.

木槿暧夏七纪年 2025-01-01 17:47:45

除了使用 AJAX 的单页加载新内容的选项之外,您还可以使用 JavaScript self.location=URL;对于必须保留在应用程序内的超链接返回 false。这可以直接添加到 HTML 代码中,或者在加载页面时使用另一个脚本添加到 HTML 代码中。

如果您使用 jQuery,我会推荐这样的内容:

$('a:not([target])').click(function(){
    self.location = $(this).attr('href');
    return false;
});

显然,这个脚本应该在 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:

$('a:not([target])').click(function(){
    self.location = $(this).attr('href');
    return false;
});

Obviously this script should be ran after the HTML has loaded, to ensure that it actually attaches to the A elements onClick event.

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