title: How to keep JS window on screen at page reload
body: <p>Im still in learning progress so thats why I turn to you guys!</p>
  
  <p>I did a sample website where I have a button in the menu for a login form.
  When pressed the javascript tells the class to put display: none; to display.</p>
  
  <p>Issue I have right now is that when I try to login on the website and the credentials are wrong the website refreshes with a header location of the issue message, making the login box dissapear / resets the default value of the box to display none.</p>
  
  <p>How can I achive that the box only closes if a person click the login box "x" or if the success login is active?</p>
  
  <pre><code>  document.getElementById('login-nav').addEventListener('click',
  function() {
    document.querySelector('.login-box').style.display = 'flex';
  });
  
  document.querySelector('.login-box-x').addEventListener('click',
    function() {
      document.querySelector('.login-box').style.display = 'none';
    });
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/KQAEN.png" rel="nofollow noreferrer">enter image description here</a></p>