[英]How to Download The same Link for Two Times?
i written Code to Download File , it's Downloading first path But it's not Downloading Second Path. 我编写了代码来下载文件,这是下载第一个路径,但不是下载第二个路径。
function Download(){
(i = 0; i < 2; i++){
window.location.href = '/Uploads/Resume/' + i + '/RAj.docx';
}
}
Try this using window.open() : 使用window.open()尝试一下:
function download(){
for(var i = 0; i < 2; i++){
window.open('/Uploads/Resume/' + i + '/RAj.docx');
}
}
window.location.href
redirects your current window
to the new URL, so all JavaScript stops to execute. window.location.href
将您当前的window
重定向到新的URL,因此所有JavaScript都将停止执行。
You can use a solution similar to @Sergio's solution: (see jsfiddle ) 您可以使用类似于@Sergio的解决方案的解决方案:(请参阅jsfiddle )
var download = function () {
for (var i = 0; i < 2; i++) {
var wnd = window.open('http://www.google.com/search?q=' + i);
wnd.focus();
}
return false;
};
document.getElementById('a').onclick = download; document.getElementById('a')。onclick =下载;
Or download your data using XMLHttpRequest
, but probably it's a better choice to use a framework like jQuery, see jQuery.ajax()
. 或使用
XMLHttpRequest
下载数据,但是使用像jQuery这样的框架可能是一个更好的选择,请参见jQuery.ajax()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.