title: How to scroll to anchor based on URL condition?
body: <p>I have some pages with content and a pagination at bottom as you can see on the picture below.</p>
  
  <p><a href="https://i.stack.imgur.com/q4Bt3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q4Bt3.png" alt="enter image description here"></a></p>
  
  <p>What I want to do is to (smooth) <strong>scroll</strong> to the anchor link if the visitor visits the second page, third page etc. (Eg. <code>www.example.com/list?page=2</code>)</p>
  
  <p>I wanted to do this with a URL condition: check if the URL has "page" string then scroll to the anchor but it didn't work.</p>
  
  <pre><code>&lt;script&gt;
      $(document).ready(function () {
          var url = window.location.href;
          if(url.indexOf("page") &gt; -1) {
              scrollTop( $("#anchor-link").offset().top );
          }
      });
  &lt;/script&gt;
  </code></pre>
  
  <p><br>
  I wonder, if using a method such that (check <strong>URL condition</strong> with JS and scroll) or to append each pagination link with <code>#anchor-link</code> is better (performance, cross-browser etc.) and how can I do that?</p>