Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

219
Visualizações
Is there a way to (re-save) an image (that already exists locally) with javascript, "without opening the image in the tab"?

I have an anchor tag that refers to an image that already exists on my local machine,

What I want is, when the user clicks on it, it downloads the image (and not open it in a tab)

The current behavior is, when I click on it, it opens the image in the browser in the same tab (or a new tab if target="_blank")

I understand that the file already exists, but I want to 're-save' it again.

I noticed the following behavior when I used this anchor tag:

<a title="title" href="localpath/image.jpg" download></a>

  • Firefox: downloads(save) the image correctly.
  • Edge: opens the image in the tab.
  • Chrome: sometimes behaves like Firefox and sometimes like Edge, (happens randomly on different machines).

I tried FileSaver.js but didn't work as I want.

I know that there has to be a server for the "download" attribute to work, but I guess there's something I'm missing.

Note: my html works on static files, it never fetches a server. and I updated my browsers to the latest versions, and cleared my cache and cookies :)

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda