Why the original window doesn't close after submit?
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function login() {
  var un = document.getElementById("username").value;
  var pw = document.getElementById("password").value;
  if (un == "admin" &amp;&amp; pw == "admin") {
    window.open("TXL.html", '_blank');
    this.window.close();
    return true;
  }
  else {
    alert("FAIL");
    return false;
  }
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="modal-body"&gt;
  &lt;form action="" class="form center-block" onsubmit="login()"&gt;
    &lt;div class="form-group"&gt;
      &lt;input type="text" id="username" class="form-control input-lg" placeholder=""&gt;
    &lt;/div&gt;
    &lt;div class="form-group"&gt;
      &lt;input type="password" id="password" class="form-control input-lg" placeholder=""&gt;
    &lt;/div&gt;
    &lt;div class="form-group"&gt;
      &lt;button class="btn btn-primary btn-lg btn-block" type="submit"&gt;Login&lt;/button&gt;
    &lt;/div&gt;
  &lt;/form&gt;
&lt;/div&gt;</code></pre>
</div>
</div>
</p>

<p>The login-window just refresh after submit.
And I tried <code>"window.open("TXL.html", '_self');"</code> and it doesn't work,even can't open the new window.
I also tried window.location.href=""; ,it still doesn't work.
Thanks for reading!</p>