Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

125
Views
Cómo descargar una página web html que contiene un formulario completo como un archivo HTML usando javascript

Tengo una página web que contiene un formulario. El usuario llenará el formulario de campos.

¿Cómo puedo guardar la página web como un archivo HTML que contiene los campos completados?

El siguiente código descarga la página web como un archivo HTML pero los campos están vacíos.

 <a onClick="this.href='data:text/html;charset=UTF-8,'+encodeURIComponent(document.documentElement.outerHTML)" href="#" download="page.html">Download</a>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Verifique el codepen.io en funcionamiento ya que la función de descarga no funciona en el marco de fragmentos de Stackoverflow.

Acabo de llenar el atributo "valor" para cada entrada con su propio valor, luego activé la descarga.

 function download(){ var hiddenElement = document.createElement('a'); var inputs = document.getElementsByTagName('input') for (var i = 0; i < inputs.length; i++) inputs[i].setAttribute("value", inputs[i].value); hiddenElement.href = 'data:attachment/text,' + encodeURI(document.getElementById("container").innerHTML); hiddenElement.target = '_blank'; hiddenElement.download = 'myFile.html'; hiddenElement.click(); }
 <div id="container"> <input value="" type="text"> <input value="" type="text"> <input value="" type="text"> <button onclick="download()">Download</button> </div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!