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

114
Vistas
create html document given a document name from html text input

im trying to create a html document with a name given from a html text input. i dont know how i can write that file to a location though; i want to write the file to a specific directory. this is what I have figured out so far:

var title = document.getElementById("docTitle").value

function append(){
    console.log("creating new document")
    createHTMLDocument(title)
    FileSystem.writeFile(title, htmlContent, (error) => {/*handle error*/});
}

the input value from the html text input is assigned to a variable which is put into the writeFile, and function append() is activated by a html button. ".html" will be put into the text input as the name so no extra code is needed to create the document specifically as html.

please help

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

0

The browser is a sandbox from which most of the user's operating system or filesystem isn't available to a website, this due to security concerns.

This means you will have to offer the file you create as if it is a download;

const button = document.getElementById('download');

function download(filename, text) {
  const element = document.createElement('a');
  element.setAttribute('href', 'data:text/html;charset=utf-8,' + encodeURIComponent(text));
  element.setAttribute('download', filename);

  element.style.display = 'none';
  document.body.appendChild(element);

  element.click();

  document.body.removeChild(element);
}

button.addEventListener('click', () => download('test', '<h1>Hello world</h1>'));
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