title: jQuery auto scroll div to div and back to top
body: <p>I found this code for autoscroll a page. </p>
  
  <pre><code>&lt;script type='text/javascript'&gt;//&lt;![CDATA[
  $(window).load(function(){
  $(document).ready(function () {
  var myInterval = false;
  myInterval = setInterval(AutoScroll, 5000);
  
  function AutoScroll() {
      var iScroll = $(window).scrollTop();
      iScroll = iScroll + 500;
      $('html, body').animate({
          scrollTop: iScroll
      }, 1000);
  }
  
  $(window).scroll(function () {
      var iScroll = $(window).scrollTop();
      if (iScroll == 0) {
          myInterval = setInterval(AutoScroll, 5000);
      }
      if (iScroll + $(window).height() == $(document).height()) {
  
          clearInterval(myInterval);
  
          setTimeout(function(){ window.location.href = "index.php"; },3000)  
  
      }
  });
  });
  });//]]&gt;  
  
  &lt;/script&gt;
  </code></pre>
  
  <p>My page looks like this:</p>
  
  <pre><code>&lt;div id="div1"&gt;&lt;/div&gt;
  &lt;div id="div2"&gt;&lt;/div&gt;
  &lt;div id="div3"&gt;&lt;/div&gt;
  &lt;div id="div4"&gt;&lt;/div&gt;
  &lt;div id="div5"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>My goal is to autoscroll from div to div after 20 seconds en after the last div back to top.</p>
  
  <p>My Question is:</p>
  
  <ol>
  <li><p>How to make it work scrolling from div to div?</p></li>
  <li><p>I use window.location.href = "index.php" for refreshing the page en start over again. Is there a different way to achieve the same without a refresh? So go back to the top div and refresh the content of the page?</p></li>
  </ol>