How do I save whole HTML page with changes in localStorage, and load it up upon browser refresh?

WITH WORKING JS*
It does not need to be HTML, it can be <body> or even <container> (in my case, container is named "refresh-div").
Project link: https://astonishing-cupcake-035f30.netlify.app/
const htmlContent = document.querySelector(".refresh-div").innerHTML;
localStorage.setItem('newPage', htmlContent);

const refressLul = document.querySelector(".refresh-div")
if(pageAccessedByReload === true) {
  refressLul.innerHTML = localStorage.getItem("newPage"); 
}

Code above is what I was doing. While it does load changed HTML, some JS is not working at all.
Any ideas on how to properly do it?

Try adding comments, saving those changes, then loading them upon refresh with all of the things working properly(reply, edit, delete etc.)
Was this page helpful?