title: how browser determine which element to give focus on page load?
body: <p>I want to know, which element will be set as active element when page completes loading.</p>
  
  <p>I tried to look into specification at <a href="https://html.spec.whatwg.org/multipage/interaction.html#dom-document-activeelement" rel="nofollow">https://html.spec.whatwg.org/multipage/interaction.html#dom-document-activeelement</a>, but I am not able to find a how browser set active element after loading page.</p>
  
  <p>And I haven't programmatically set focus to any of element.</p>
  
  <p>One way to track, i found is</p>
  
  <pre><code>if (document.addEventListener) {
    document.addEventListener("focus",_dom_trackActiveElement,true);
    document.addEventListener("blur",_dom_trackActiveElementLost,true);
  }
  </code></pre>