title: Can I avoid html resetting my javascript variable when I use location.href?
body: <p>My new project is a small "puzzle" game where you enter a room and solve a puzzle inside, then when you go back to the level select section it opens up the next level. </p>
  
  <p>I have thus far been using a single variable "lock" to count up once every time you beat a level and if the value of "lock" corresponds with the level number it would let you through.</p>
  
  <p>Problem is that it seems when I use <code>location.href</code> it resets the "lock" variable. </p>
  
  <p>Html for level select:</p>
  
  <pre><code>//html, link to js and some text
  &lt;h1&gt;
  &lt;img src="assets/Nextbutton1.png" onclick="t1()" width="100" //1st level button
  height="100"&gt; &lt;br&gt;
  &lt;img src="assets/Nextbutton2.png" onclick="t2()" width="100" //2nd level button
  height="100"&gt;
  </code></pre>
  
  <p>Win screen html</p>
  
  <pre><code>&lt;body&gt;
  &lt;h1 align="center"&gt; Congratulations&lt;/h1&gt;
  &lt;button align="center" onclick="joo()"&gt;Back to level select&lt;/button&gt; 
  </code></pre>
  
  <p>Javascript for pretty much everything</p>
  
  <pre><code>var lock;
  var taso2;  // future stuff
  var taso3 = 2; //future stuff
  
  function joo(){
  
  location.href='index.html'
  if (lock == 0) // if statement so you dont progress by playing 1st level over and over
  {
  lock += 1;}
  }
  
  function t2() {
  if (lock &gt; 0) {
  location.href='Taso2.html';
  }
  else { alert("You have to beat the previous levels first") }
  }
  
  function t1() {
  location.href='Taso1.html';
  }
  </code></pre>