gpt4 book ai didi

ios - 链接不会在 iOS 独立网络应用程序的 iframe 目标中打开

转载 作者:行者123 更新时间:2023-11-28 18:31:53 25 4
gpt4 key购买 nike

我遇到了泡菜。当我通过 iOS 6 在移动 safari 中查看我的网络应用程序时,我能够成功打开我的基本目标链接 <a href="link.html" target="mainframe"进入我的回顾性 iframe <iframe src="http://www.linkexample.org/" name="mainframe"></iframe>

虽然当通过独立方式打开应用程序时,所有链接都会退出应用程序并进入 Mobile Safari。您可以在 http://lacitilop.com/m2 查看工作示例

有人对如何解决这个问题有任何建议吗?

最佳答案

您需要编写一些 javascript 来更改 iframe 的 src

首先,让您的应用正常工作,这样链接就不会打开 Safari,方法如下(顺便说一句,它使用的是 jquery):

if (window.navigator.standalone) {

$(document).on(
"click",
"a",
function (event) {

event.preventDefault();

var aurl = $(event.target).attr("href");
if (aurl) {
location.href = $(event.target).attr("href");
}
else {
location.href = this;
}
}
);
}

然后您需要对其进行修改以使其也适用于 iframe。

有关更多 iphone 应用程序的内容,您需要查看以下内容:

http://developer.apple.com/library/safari/#documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html

关于ios - 链接不会在 iOS 独立网络应用程序的 iframe 目标中打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14049315/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com