title: jQuery Smooth Scrolling to anchor on different page
body: <p>My jQuery smooth scroll works if an element is linked to an anchor on the same page but it does not smooth scroll when linked to an anchor on a different page.</p>
  
  <p>Are there any obvious problems with my jQuery script?</p>
  
  <pre><code>&lt;script&gt;
  jQuery(function($) {
  
      // //////////////////////// Smooth Scroll To Specific Element On Page ////////////////////////
  
      $(document).ready(function() {
          $('a[href^="#"]').not('.carousel-control-prev').not('.carousel-control-next').bind('click.smoothscroll', function(e) {
              e.preventDefault();
  
              var hash = this.hash;
  
              jQuery('html, body').animate({
                  scrollTop: jQuery(hash).offset().top - 65
              }, 1500, function(){});
          });
      });
  
      //////////////////////// Smooth Scroll To Specific Element On Different Page ////////////////////////
  
      $(document).ready(function(){
          var urlHash = window.location.href.split("#")[1] || false;
          if (urlHash.length &gt; 0)
              $('html,body').animate({
                  scrollTop: $('#' + urlHash).offset().top - 60
              }, 2500);
      });
  
  });
  &lt;/script&gt;
  </code></pre>