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

202
Vistas
'Click' event not working within typescript/angular after appendChild

if (CSV == '') { alert("Invalid data"); return; }

  const uri = 'data:text/csv;charset=utf-8,' + escape(CSV);
  const link = document.createElement("a");
  link.href = uri;
  link.download = "Payments.csv";
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(link);

When i am tryinng to download the file, " link.click " is not firing not getting any console errors.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This line has an issues

document.body.removeChild(link);

You can remove it and add the below code for hiding your link from the document

link.setAttribute('style', 'display:none;');

Complete snippet code

const uri = 'data:text/csv;charset=utf-8,' + escape(CSV);
const a = document.createElement("a");
document.body.appendChild(a);
a.href = uri;
a.download = "Payments.csv";
a.target = 'blank';
a.click();

I hope you will be clear with this info

about 4 years ago · Juan Pablo Isaza Denunciar
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