Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
Javascript Download Attribute renaming not working multiple files download

This code is working to download the files, however It is not letting me rename file. Using chrome103. After a page refresh, it works if I rename to a specific filename"123.txt", but not a generated name

''' $("Download2").appendTo($("#td- createnew")).css({"height":"27.99","font-family":"verdana,Geneva,Sans-Serif","font- size":"12px","border-radius":"6px","box-sizing":"border-box","border":"1px solid #aab3b6","line-height":"16px","margin":"2px","padding":"5px","vertical-align":"middle","font- weight":"500","text-transform":"uppercase","font-stretch":"100%","width":"150"});

$("#downloadbtn2").click(function(){
download_all();
})

function download_all(){
    var listItems = document.querySelectorAll(".ui-state-active");
    var array = [];
    var filenames = [];

for (var i=0;i<listItems.length;i++){
    var link = listItems[i].getElementsByTagName('a')[3].href;
    array.push(link);
    x=link.split("&")[2];
x=x.split("=")[1];
y=link.split("=")[4];
filenames.push(x+y);
    
    console.log(filenames);
}

urls=array;


var interval = setInterval(download, 300, urls,filenames);

function download(urls,filenames) {
var url = urls.pop();
var fname=filenames.pop();

var a = document.createElement("a");
a.setAttribute('href', url);
a.setAttribute('download', fname);
a.setAttribute('target', '_blank');
a.click();

if (urls.length == 0) {
    clearInterval(interval);
}}}

'''

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!