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

171
Visualizações
Save Html source from browser with JS

I would like to create a simple Html list application on my local computer with save functionality locally, new list items added to the list and saved. I was searching online but I have found only complicated solutions that required an input object to save. I would like to ask if the following code can work with some modification.

index.html

<html lang="en">
<head>
    <title>App</title>
</head>

<body>
Content...
        <button onclick="save()">Save</button>
</body>
<script src="setup.js"></script>
</html>

setup.js

async function save(content){
    let fileData = new File([""], "index.html");
    let stream = fileData.createWritable();
    let text = "text";
    await stream.write(text);
    await stream.close();
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you are running a very recent Chromium browser, you can use window.showSaveFilePicker. ([https://developer.mozilla.org/en-US/docs/Web/API/Window/showSaveFilePicker]) From the docs:

function getNewFileHandle() { 
  const opts = {
    types: [{
      description: 'Text file',
      accept: {'text/plain': ['.txt']},
    }],
  };
  return window.showSaveFilePicker(opts);
}
async function writeFile(fileHandle, contents) {
// Create a FileSystemWritableFileStream to write to.
  const writable = await fileHandle.createWritable();
  // Write the contents of the file to the stream.
  await writable.write(contents);
  // Close the file and write the contents to disk.
  await writable.close();
}
about 4 years ago · Juan Pablo Isaza Relatório
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