2014-11-25 19 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> 
相關問題