title: Javascript: Redirect page onclick
body: <p>I'm fiddling around with a pretend "Logon screen" but am having trouble when it comes to redirecting the page.</p>
  
  <p>I've tried a couple of different suggestions that I've found on the site, but so far nothing has worked.</p>
  
  <p>I honestly think I'm just doing it wrong.</p>
  
  <p>Any advice?</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;div class="title"&gt;&lt;h1&gt;Webby Site&lt;/h1&gt;&lt;/div&gt;
  &lt;div class="login-page"&gt;
    &lt;div class="form"&gt;
      &lt;form class="login-form"&gt;
        &lt;input id="User" type="text" placeholder="username"/&gt;
        &lt;input id="PWord" type="password" placeholder="password"/&gt;
        &lt;button class="button"&gt;Login&lt;/button&gt;
        &lt;p class="message"&gt;Not registered? &lt;a&gt;Create an account&lt;/a&gt;&lt;/p&gt;
      &lt;/form&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>JS</strong></p>
  
  <pre><code>$(document).ready(function(){
         $('.button').click(function(){
              if ($('input#User').val() === "1" &amp;&amp; $('input#PWord').val() === "1"){
              document.location.href = "www.yoursite.com";
              } else {
                  alert('Incorrect Account Details');
              }
          });
      });
  </code></pre>
  
  <p>Code I've tried (in the same area as <code>document.location.href</code>)</p>
  
  <ol>
  <li><code>document.location</code> </li>
  <li><code>window.location</code></li>
  <li><code>window.location.href</code></li>
  <li><code>location.href</code></li>
  </ol>