title: How to scroll an HTML page to a given anchor
body: <p>I’d like to make the browser to scroll the page to a given anchor, just by using JavaScript.</p>
  <p>I have specified a <code>name</code> or <code>id</code> attribute in my HTML code:</p>
  <pre><code> &lt;a name=&quot;anchorName&quot;&gt;..&lt;/a&gt;
  </code></pre>
  <p>or</p>
  <pre><code> &lt;h1 id=&quot;anchorName2&quot;&gt;..&lt;/h1&gt;
  </code></pre>
  <p>I’d like to get the same effect as you’d get by navigating to <code>http://server.com/path#anchorName</code>. The page should be scrolled so that the anchor is near the top of the visible part of the page.</p>