How to write to a seperate html file in plain browser javascript?

I know that you can write to the current HTML document, but I want to write to another html file.
For example:
I have 2 files, one is index.html, and the other is completedsurvey.html
I want to write something to the completedsurvey.html from my index.html file. Is there a way
to do this that is supported in most browsers?

53 thoughts on “How to write to a seperate html file in plain browser javascript?”

  1. So for the first solution:
    Assuming you’d want to display "username" and "summary" on successful submission of the form.
    This isn’t an exact solution, just something you can use to get the concept.


        <input type='text' id="username">
        <input type='text' id="summary">
        <button type="button" id="process-form">
           document.getElementById('process-form').addEventListener('click', (eve)=>{
              var uname = document.getElementById('username');
              var summ = document.getElementById('summary');
              localStorage.setItem('uname', uname);//saving the data in local storage
              localStorage.setItem('summ', summ);
    //redirect to next page...


    <h1 id="name"> </h1>
    <p id='summary'> </p>
      var uname = localStorage.getItem('uname');//retrieving from local storage
      var summ = localStorage.getItem('summ');
      document.getElementById('name').innerHTML = uname;//fill the fields with data 

    Further Links:


Leave a Comment