Home > Net >  Is it possible to "update data" to and "existing html template" and then "s
Is it possible to "update data" to and "existing html template" and then "s

Time:09-30

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 >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?

CodePudding user response:

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:

  • Related