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

198
Views
'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 answers
Answer question

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 Report
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!