title: JavaScript scrollIntoView function does not work - the page does not scroll into the element view
body: <p>I have a web page (using HTML, CSS, JavaScript, PHP) and want to write some script to scroll my page to one of elements on it. </p>
  
  <p>This worked well (when I clicked on the button, the page scrolled into view of <code>search_cont</code> element:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;?php  include_once('head.php'); ?&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;button onclick="myFunction()" id="scroll"&gt;Scroll&lt;/button&gt;
    &lt;script&gt;
      function myFunction() {
        var elmnt = document.getElementById("search_cont");
        elmnt.scrollIntoView();
      }
    &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>However, this thing did not do anything:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
    &lt;?php  include_once('head.php'); ?&gt;
  &lt;/head&gt;
  &lt;body onload="myFunction()"&gt;
    &lt;script&gt;
      function myFunction() {
        var elmnt = document.getElementById("search_cont");
        elmnt.scrollIntoView();
      }
    &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My question is, why this did not work, and how can I fix it? Or (alternative question), how can I scroll (right after the page is loaded) to some element on the page another way? - without using the (visible) button I have to click on. </p>
  
  <p>I'll be very grateful for your responds.</p>