title: Trigger Scroll toTop after window.location.replace JQuery
body: <p>I hope someone could help me resolve this programming problem I am having. </p>
  
  <p>I have a footer.php file that links to a series of bs-tab groups on another page - let's say about.php (for argument's sake). The task flow I am looking to complete using JQuery is as follows: </p>
  
  <p>(Let's say we are on index.php)</p>
  
  <ol>
  <li>Click the link in footer.php to a tab group on about.php.</li>
  <li>Link routes through to the correct tab group.</li>
  <li>Loads the page and finishes by scrolling to the top of the page. This mimics the rest of the site's page loading behaviours. Which is why this needs to happen.</li>
  </ol>
  
  <p>The issue I am having is that when on the same page that these tab groups reside (about.php) the link works fine: </p>
  
  <p>click event > tab group changes > active nav-tab state toggles > page scrolls to top</p>
  
  <p>When on another page however (say from index.php routing to about.php), the following happens: </p>
  
  <p>click event > tab group changes > active nav-tab state toggles > hash anchor butts to the top of the page, but does not scroll to top of page.</p>
  
  <p>I have run a quick test and found that the sequence seems to have problems after we change from index.php to about.php: </p>
  
  <pre><code>window.location.replace(link_url);
  </code></pre>
  
  <p>How can I complete the programming sequence once the window location has changed? </p>
  
  <p>Here is my code and thank you in advance:</p>
  
  <p>HTML - found in footer.php:</p>
  
  <pre><code> &lt;div class="col-lg-3 col-md-3 col-sm-3 col-xs-6 footer-links"&gt;
          &lt;h3&gt;Tab Groups&lt;/h3&gt;
          &lt;ul&gt;
          &lt;li class="tab1"&gt;&lt;a class="active" href="/link#hashtag1" data-toggle="tab"&gt;hashtag1&lt;/a&gt;&lt;/li&gt;
          &lt;li class="tab2"&gt;&lt;a href="/link#hashtag2" data-toggle="tab"&gt;hashtag2&lt;/a&gt;&lt;/li&gt;
          &lt;li class="tab3" &gt;&lt;a href="/link#hashtag3" data-toggle="tab"&gt;hashtag3&lt;/a&gt;&lt;/li&gt;
          &lt;/ul&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>JS: </p>
  
  <pre><code>$('.footer-links a').on('click', function(e) {
  
      var link_url = $(this).attr('href');
      var link_hash = link_url.substring(link_url.indexOf('#')+1);
      var totalLink = window.location.pathname + '#' + link_hash;
  
      if (totalLink !== link_url) {
          window.location.replace(link_url);
      }
  
      $(this).tab('show');
  
      $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
          var activeTab = this.href.split('#');
          $('.nav a').filter('[href="#'+activeTab[1]+'"]').tab('show');
      });
  
  //below doesn't happen after the page loads
  
      if($(window).scrollTop() &gt; 0){
          $('html, body').animatescroll({scrollSpeed:1000,easing:'easeOutQuint',padding:0});
      } else {
          $(window).scrollTop(0);
      }
  
  });
  </code></pre>