1

HTML5 download attribute with url working for me but it is redirecting me to new page. Here is my code -

exportToPdf: function(e) {
 var link = document.createElement('a');
 link.href = 'https://filegenerator.com/download?guid=d85c9ca87a374df1a81b1503406ebead';
 link.download = "Report";
 link.click();
}

HTML code-

 <a id="exportToPdf">Export to PDF</a>

enter image description here

Also tried doing this way -

<a download="" href="https://filegenerator.com/download?guid=d85c9ca87a374df1a81b1503406ebead" id="exportToPdf">Export to PDF</a>

But not working. Please suggest any other way of doing this.

shahista inamdar
  • 176
  • 2
  • 12

1 Answers1

0
<a download="" href="https://filegenerator.com/download?guid=d85c9ca87a374df1a81b1503406ebead" id="exportToPdf">Export to PDF</a>

This is working completely fine as I had written a code for click of anchor and was redirecting it to new page using window.open(url). Because of that it was redirecting.

shahista inamdar
  • 176
  • 2
  • 12