解决。
我有一个安装ios app的链接,可以在safari中使用。
<a href="itms-services://?action=download-manifest&url=https://acqshop.com/manifest/category/Farsi/ashpazi.plist"></a>
现在我想要隐藏用户的链接。但我不知道该怎么做。 我使用onclick获取链接:
<a href="javascript:void(0);" onclick="javascript:install();" target="Farsi/ashpazi.plist"></a>
function install() {
if (!isMobile()) {
alert('you can download from ios devices');
return;
}
var post_link = $(this).attr("target");
url = 'install.php?name='+post_link;
window.location.href = url;
}
并在install.php中:
<?php
$name = $_GET['name'];
$path = 'itms-services://?action=download-manifest&url=https://acqshop.com/manifest/category/'.$name;
$mm_type="application/octet-stream";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-Type: " . $mm_type);
header("Content-Length: " .(string)(filesize($path)) );
header('Content-Disposition: attachment; filename="'.basename($path).'"');
header("Content-Transfer-Encoding: binary\n");
readfile($path); // outputs the content of the file
exit();
?>
但它不起作用。我错了。
你可以在这个网站上看到一个onclick函数的例子来下载ios app:
ipa.othman.tv/ipa/vi2.php
但我无法理解installvi2.php中的功能
(请参阅页面来源)
感谢。
感谢@Shynggys 我将install.php更改为:
<?php
$name = $_GET['name'];
$path = 'itms-services://?action=download-manifest&url=https://acqshop.com/manifest/category/'.$name;
$mm_type="application/octet-stream";
header("Pragma: public");
header("Expires: 0");
header('Location:' .$path);
?>
答案 0 :(得分:0)
尝试使用绝对URL,而不是相对URL,并从函数'install'返回'false',它应该如下所示:
function install() {
if (!isMobile()) {
alert('you can download from ios devices');
return;
}
var post_link = $(this).attr("target");
url = 'http://MyWebSite.kz/install.php?name='+post_link;
window.location.href = url;
return false;
}
希望有所帮助