0

是否可以在显示文本的网站上的 android 浏览器中开始下载?

我想要这样的东西:

Your download started allready. What are your next steps? [Description ...]
The Download did not start? <a href="download_location">Fallback link</a>

似乎一个不可见的 iframe 在 android 上根本不起作用。(在我的电脑上它工作正常)。我试过这个下载 javascript https://stackoverflow.com/a/3749395/446140但这也只适用于我的电脑。我的下一个解决方法是创建一个 download.html 将用户重定向到要下载的文件:

索引.html:

<html>
<head>
<script type="text/javascript">
var downloadURL = function downloadURL(url) {
    var hiddenIFrameID = 'hiddenDownloader',
        iframe = document.getElementById(hiddenIFrameID);
    if (iframe === null) {
        iframe = document.createElement('iframe');
        iframe.id = hiddenIFrameID;
        iframe.style.display = 'none';
        document.body.appendChild(iframe);
    }
    iframe.src = url;
};
</script>
</head>
<!-- Probably a explicit iframe would do the same here... -->
<body onLoad="downloadURL('download.html')">
Your download started allready [...]
</body>
</html>

下载.html:

<html>
<head>
<META HTTP-EQUIV="refresh" CONTENT="0;URL=<filetodownload>">
</head>
</html>

它适用于我的 Android 4.x 手机,但不适用于 2.3。

如果我在 Android 2.3 上尝试 Opera,它可以工作,但默认浏览器不想下载该文件。

有什么我可以做的吗?或者这根本不适用于 android < 4.x?我是否可能需要创建明确设置内容类型的 php/... 脚本?

4

0 回答 0