How to handle anchor with download attribute and HTTP 404 - Firefox

38 Views Asked by At

I'm using the download attribute on an anchor (link).

In some rare cases, I know that I'll have a 404 error (file not found).

Chromium based browsers handle it by showing a Download failed - No file in the download pane. This seems right to me.

Firefox on the other hand, does not show any error message and only opens a blank 'New tab'.

Is this a normal Firefox behavior? I this a Firefox bug ? Am I doing it wrong ?


  • In the case of a non-200 HTTP code, I would like the user to be informed

  • If possible, I would like to avoid the use of JS

  • The download URL (href) is on the same domain to comply with the same-origin policy.

  • Here is an CodePen example (don't run on stackoverflow snipet for same-origin policy) : https://codepen.io/random-bytes/pen/xxBLdYr

0

There are 0 best solutions below