2014-11-25 20 views

回答

0

在显示消息的地方<meta http-equiv="refresh" content="3;url=/download url" /><head>部分的页面。这会在3秒后将请求重定向到下载URL。

+0

我用这个用图片下载的尝试,但它显示我3秒后在页面上的图像,而不是下载它 – user3789138 2014-11-25 10:38:17

+0

发布您的代码。 – 2014-11-25 10:40:42

0

您需要准备下载页面并附上超时脚本,以便在2-3秒后下载。在你的图标

添加的onclick功能类似下面的代码:

<img id="downloadBtn" onclick="window.open('<put link to the download page here>')" /> 

在您的下载页面上,添加脚本像下面的代码:

<html> 
<head> 
<title>Download page</title> 
</head> 
<body> 
<h1>Thank you for downloading</h1> 
<p>Your download will start in <span id="countdown">5</span> seconds</p> 

<script type="text/JavaScript"> 
var countdown = document.getElementById("countdown"); 
var wait = 5; 
var timeout = setInterval(function(){ 
    wait--; 
    countdown.innerHTML=wait; 
    if (wait == 0){ 
     clearInterval(timeout); 
     location.href="<link to the download file goes here>"; 
    } 
},1000); 
</script> 
</body> 
</html> 
相关问题