【发布时间】:2015-12-17 19:32:51
【问题描述】:
我的问题是关于仅限 iOS9!
我有一个HTML 登录页面,如果安装了应用,我会尝试通过 URL 方案将用户重定向到我的应用,或者重定向到 Appstore否则。
我的代码是:
document.addEventListener("DOMContentLoaded", function(event) {
var body = document.getElementsByTagName('body')[0];
body.onclick = function () {
openApp();
};
});
var timeout;
function preventPopup() {
clearTimeout(timeout);
timeout = null;
window.removeEventListener('pagehide', preventPopup);
}
function openApp(appInstanceId, platform) {
window.addEventListener('pagehide', preventPopup);
document.addEventListener('pagehide', preventPopup);
// create iframe
var iframe = document.createElement("iframe");
document.body.appendChild(iframe);
iframe.setAttribute("style", "display:none;");
iframe.src = 'myscheme://launch?var=val';
var timeoutTime = 1000;
timeout = setTimeout(function () {
document.location = 'https://itunes.apple.com/app/my-app';
}, timeoutTime);
}
问题是 iframe 技巧在 Safari iOS9 中不起作用。
知道为什么吗?
我的iframe 技巧基于this 答案。
【问题讨论】:
-
openApp 是否重定向到 safari
-
@Anbu.Karthik 你是什么意思?
-
对不起,在你的情况下是否重定向到 safari
-
但我想尽可能切换应用(如果不可能,则不显示任何警报)或重定向到应用商店。我不想以任何方式重定向..
-
朋友,我不懂javascript,但我在iOS中的三个以上应用程序上都研究过URL架构,我一定支持你找到解决方案,
标签: javascript ios iframe safari ios9