Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

260
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda