Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

511
Vistas
html/js how to ask the user where to download a file

I would like to make an html file that contains a button that when clicked, asks the user where to download a js generated file to. For example, here is a screenshot of my firefox browser prompting me to decide where I want to save a file I am about to download off a webpage.

example

Currently my solution is the following code:

<script>
    function download(filename, text){
        let element = document.createElement('a')
        element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text))
        element.setAttribute('download', filename)
        element.click()
    }

    download("hello.txt","This is the content")

</script>

However the popup does not ask where to save the file to as seen here:

enter image description here

How can I replicate the first situation with JS and HTML?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This depends entirely on the browser's implementation and is not something you can control with Javascript.

In this case the user would have to select save file.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda