title: How to reverse display=none on browser history back click?
body: <p>On my page I have a javascript function that changes the current URL via pushState and hides a specific div when a user clicks on the text &quot;close&quot;. The simplified page looks like this:</p>
  <pre class="lang-html prettyprint-override"><code>&lt;div id='book'&gt;
    &lt;a onclick='close();'&gt;close book information&lt;/a&gt;
    Book Information
  &lt;/div&gt;
  &lt;div id='booklist'&gt;List of all books&lt;/div&gt;
  
  &lt;script&gt;
  function close() {
      /* ... */
      document.getElementById(&quot;book&quot;).style.display = &quot;none&quot;;
      window.history.pushState({path:newurl},'',newurl);
  }
  &lt;/script&gt;
  </code></pre>
  <p>So the URL is &quot;book.php?id=1&quot; and shows information about one book on top of the books' list. If the user clicks on the close button, the URL changes to &quot;book.php&quot; and the book is hidden.
  However, if the user opens other books and then clicks the back button of their browser, the URL will change back to &quot;book.php?id=1&quot; but display=none is still active. How can I reverse the javascript that was done before? Refreshing the page would also be fine. I found <a href="https://stackoverflow.com/questions/24568544/reload-page-on-browser-history-back-button">this answer</a> but since I cannot change the body tag, it doesn't work for me.
  I hope that you might have an idea how to solve this.</p>