0

I have a basic template file of which I want to update data and then "save it" as a brand new separate html file.

Is it possible to do with Vanilla JavaScript?

Here is my example code:

window.onload = (event) => {

  function updateData(newData) {
    const toUpdate = document.getElementsByClassName('toUpdate')[0];
    toUpdate.innerText = 'Updated!'
  }

  updateData('Updated!')
};

// How can I save this html as a separate new html file with vanilla Javascript?
<!DOCTYPE html>
<html>

<head>
  <title>Document</title>
</head>

<body>
  <h1 class="toUpdate">Not updted</h1>
</body>

</html>
<!-- How can I save this html as a separate new html file with vanilla Javascript?  -->

Is it possible to achieve this with Vanilla JavaScript?

Pro Girl
  • 762
  • 7
  • 21

1 Answers1

1

Vanilla JavaScript (typically defied as JavaScript + Web APIs provided by browser without third party libraries or browser extensions) cannot save files per se.

You can:

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335