title: Redirecting to URL in external Javascript function not working
body: <p>I'm currently trying to program a relatively simple site, but my HTML and Javascript skills are pretty basic. Basically, what I'm trying to do is create a page where the user is asked a question which they answer by typing it into a form. With an external Javascript function the users answer is compared to the right one, and if they're the same, the user is supposed to be redirected to a different site. 
  Here's the form in my HTML document:</p>
  
  <pre><code>&lt;FORM NAME="myform" ACTION="" METHOD="GET"&gt; Answer:
      &lt;INPUT TYPE="text" NAME="inputbox" VALUE=""&gt;
      &lt;button onClick="checkAnswerExact(this.form)"&gt; Submit &lt;/button&gt; 
  &lt;/FORM&gt;
  </code></pre>
  
  <p>My Javascript function looks like this:</p>
  
  <pre><code>function checkAnswerExact(form){ 
    //GET ANSWER
    var x = form.inputbox.value;
    //CONVERT ANSWER TO STRING
    var TestAnsw =x.toString();
    //DEFINE RIGHT ANSWER
    var RightAnsw = "rightanswer";
    //CHECK IF THEY ARE THE SAME
    if (TestAnsw.toLowerCase() == RightAnsw.toLowerCase() ){ 
      alert("The answer is right.");
      window.location.href = 'https://www.reddit.com/';
    } //WHAT TO DO IF ANSWER'S RIGHT
    else {
      alert("The answer is wrong.");
    } //WHAT TO DO IF ANSWER'S WRONG  
  }
  </code></pre>
  
  <p>As an example site to redirect it to, I chose reddit. The alerts work right, so the comparison of the strings is okay. I've been googling for a while now and read through a bunch of forums but nothing seemed to work for me. I've tried <code>document.location=url</code>, and <code>window.replace(url)</code> both inside the if-else statement and outside and nothing seems to work, the window only reloads. What does work is <code>window.open(url)</code>, but I don't want it to open in a new tab. I'm using Chrome as my browser, if that's relevant.</p>
  
  <p>I'd love some help, I've been researching for some hours and I'm pretty sure it's probably some mistake I made that I can't see.<br>
  Cheers!</p>