title: Javascript redirect on form submit depending on input
body: <p>I'm working on a simple javascript quiz, and I can't for the life of me get Javascript to submit the form and open the result in the same page, regardless of whether I use location.href, open.window, or whether I set "_self" as the target. Doesn't seem to matter what I do...</p>
  
  <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 answer() {
    var response = document.getElementById('answer').value;
    if (response == "correctanswer")
      location.href('right.html');
    else
      location.href('wrong.html');
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form onSubmit="answer()" id="answer" target="_self"&gt;
    &lt;input type="text" maxlength="55" class="box" autofocus /&gt;
    &lt;input type="submit" class="submit" value="SUBMIT" /&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>So, what I want to happen is, when the user submits the form, they go to "right.html" if they typed <em>correctanswer</em> into the text box, or "wrong.html" if they typed anything else.</p>
  
  <p>I've got it running fine, except for the fact that no matter what I do I can't get the resulting page to open in <code>_self</code>, but rather in another window. Every time.</p>
  
  <p>Been driving me crazy all night.</p>