![](/img/trans.png)
[英]How can I create a for loop which increments a number until it finds the one which's remainder is 0?
[英]How can I allow the user input a # , which finds one of my local zip files with correct # and proceeds to download it?
我當前正在創建一個簡單的HTML頁面,該頁面允許用戶輸入“#”,然后單擊一個按鈕,它將下載相應的“#.zip”。
<!DOCTYPE html>
<h2>Enter FileName # to start download...</h2>
<input type="text" id="refID" title="Enter FileName # to start download">
<button type= "file" onclick="Download()">Download</button>
<script>
function Download() {
var x = document.createElement('a');
var y = "ModifiedIndex/"+document.getElementById("refID").value+".zip";
x.href = y;
}
</script>
我希望進行下載,但是該頁面將變為空白,或者什么都不做,而是停留在該頁面上。
可能導致頁面空白的是<button type="file">
。 type="file"
不存在,因此回退到提交表單的默認值。 (沒有一個可見的,但是如果實際代碼中有一個……)使用type="button"
。
導致下載無法進行的原因是,您正在創建鏈接,設置鏈接的位置以及將鏈接丟棄。 導航到URL:
function Download() {
location.href = "ModifiedIndex/"+document.getElementById("refID").value+".zip";
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.