Leonel Matias Domingos
Leonel Matias Domingos

Reputation: 2060

HTML DOM click() in Edge

I have this code

 var link = document.createElement("a");
    document.body.appendChild(link);
    link.download = initCaps(obj.tableId) + '.csv';
    link.href = event.data;
    link.click();
    link.remove();

Link html :

<a href="data:text/csv;charset=UTF-8,%EF%BB%BF;Empresa;Utilizador;Projeto;Tarefa;Local;Dt.%20In%C3%ADcio;Dt.%20Fim;%C3%82mbito;Fatur%C3%A1vel;Dura%C3%A7%C3%A3o;Minutos;Kms;Descri%C3%A7%C3%A3o;Estado;%0A;CMIP;PMA;QUAD-HR;Levantamento%20necessidades;Lousado;2017-09-22;2017-09-27;Consultoria;Sim;00:06;6;6;66666;Validado;%0A;CMIP;PMA;QUAD-HR;
..........
download="Timesheets.csv"></a>

this works fine in chrome and firefox but not on Edge. Everything is fine but click dont work. File is not downloaded.

Upvotes: 0

Views: 242

Answers (1)

Asmarah
Asmarah

Reputation: 134

First of all your Edge should be of version 13 or greater for download attribute to work. Secondly, Please see below links Download attribute on A tag not working in IE

Upvotes: 2

Related Questions