Multiple File Download Using Javascript Not Working
I am using the javascript to download multiple file from url. I have used the following url to do this but not find any solutions, Its working fine for firefox and google chrome bu
Solution 1:
I have solved it with following code--> Maybe it helps somebody.
functiondownload_files(files) {
functiondownload_next(i) {
if (i >= files.length) {
return;
}
var a = document.createElement('a');
a.href = files[i].download;
a.target = '_blank';
if ('download'in a) {
a.download = files[i].download;
}
(document.body || document.documentElement).appendChild(a);
if (a.click) {
a.click(); // The click method is supported by most browsers.
}
else {
window.open(files[i].download);
}
console.log('1');
a.parentNode.removeChild(a);
setTimeout(function() {
download_next(i + 1);
}, 5000);
}
// Initiate the first download.download_next(0);
}
functiondo_dl() {
download_files([
{ download: "https://www.example.com"},
{ download: "https://www.example.com"},
{ download: "https://www.example.com"},
{ download: "https://www.example.com"},
]);
};
do_dl();
Solution 2:
I had the same issue. A fix that worked for me was to change target of a
tag to _blank
target and allow in browser for Popups permissions.
Post a Comment for "Multiple File Download Using Javascript Not Working"