0

I have a hidden icon on my page that has an href attribute that calls an Umbraco surface controller

<a class="fas fa-file-pdf" id="download-pdf-icon" aria-label="Download PDF" href="/umbraco/Surface/BenefitStatementPdfSurface/BenefitStatementPdf?memberNumber=23123080&amp;selectedYear=2017&amp;pageId=1505">
    <span class="visually-hidden">Download PDF</span>
</a>

I have a button that triggers the click event of the icon to download the PDF returned by the surface controller

I would like to amend the label of the button to a spinner whilst waiting for the PDF to download and then reset the label once completed but there does not seem to be a way to do this as there is no event to liste/wait for for completion

Ideally, something like this would work

$(".download-pdf-button").on("click tap touchstart", function () {
    $(this).text("Waiting...");
    $("#download-pdf-icon")[0].click();
    $(this).text("Completed");
});

Is there no event I can listen for or callback I can set?

rrk
  • 15,677
  • 4
  • 29
  • 45
Mike
  • 2,391
  • 6
  • 33
  • 72
  • 2
    No. There's no events for when a download starts or ends. You can determine that the `a` was clicked, but you cannot know when the download completes - or even that the user started/cancelled it. – Rory McCrossan Jun 20 '19 at 08:45
  • 2
    check this out https://stackoverflow.com/questions/1106377/detect-when-browser-receives-file-download – Jaydeep Jun 20 '19 at 08:47

0 Answers0