我想创建一个显示消息的PHP页面
Your download will begin shortly.
If it does not start, please click here to restart the download
Run Code Online (Sandbox Code Playgroud)
即,主要网站上存在的相同类型的页面.
它会像这样工作:
<a href="download.php?file=abc.zip">Click here</a>
Run Code Online (Sandbox Code Playgroud)
当用户点击该链接时,他将被引导到download.php,向他显示该消息,然后提供该文件以供下载.
我怎样才能做到这一点?
非常感谢!
该链接需要执行以下两件事之一:
让浏览器“自行”开始下载的一种方法是使用 META REFRESH 标记。
另一种方法是使用 JavaScript,例如(来自 Mozilla 的 Firefox 下载页面):
function downloadURL() {
// Only start the download if we're not in IE.
if (download_url.length != 0 && navigator.appVersion.indexOf('MSIE') == -1) {
// 5. automatically start the download of the file at the constructed download.mozilla.org URL
window.location = download_url;
}
}
// If we're in Safari, call via setTimeout() otherwise use onload.
if ( navigator.appVersion.indexOf('Safari') != -1 ) {
window.setTimeout(downloadURL, 2500);
} else {
window.onload = downloadURL;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3385 次 |
| 最近记录: |