title: If visited url contains #, do nothing, else redirect
body: <p>I want the visitors of my one-page horizontal website to be redirected to the part that is considered 'Home' (it's in the center of the body). Right now, when they visit the main URL, they will just see the most left part of the horizontal website.</p>
  
  <p>The thing is, I want to be able to share other parts of the website by anchor link, without my visitors being redirected to the #Home anchor.</p>
  
  <p>So what I basically want is:</p>
  
  <ul>
  <li>if the visited URL contains #, do nothing (since all anchor links contain #)</li>
  <li>if the visited URL does not contain #, redirect to the #Home anchor. (if it doesn't contain a #, I consider the url either invalid, or they are just visiting the homepage without an anchor in the URL.</li>
  </ul>
  
  <p>Right now, I have this JS code:</p>
  
  <pre><code>if (window.location.href.indexOf('#') &gt; -1){
      // do nothing   
  }
  else {
      top.location.href = "http://www.url.com/#Home";
  }
  </code></pre>
  
  <p>What's wrong with this code, and how I should do this the proper way?</p>