title: Run onload event in the body tag of HTML before the window focus event
body: <p>I want to call an onload event before an focus event in a HTML page.
  In my following code </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;body onload='onloading()'&gt;
  &lt;script src="jquery.min.js"&gt;&lt;/script&gt;
  &lt;script&gt;
  $(document).ready(function(){
      $(window).focus(function(){
  
          callMe();
      });
  });
  
  function callMe()
  {
      alert('Focus is on current page');
  }
  
  function onloading()
  {
      alert('Onload function call ');
  }
  function myFunction() 
  {
    document.write("some text");
  }
  document.getElementById("demo").innerHTML = myFunction(); 
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;p id="demo"&gt;&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When I execute this code then i get an a pop up as "Focus on current page " and in the back ground " some text" . But I expect to get an output in the following order </p>
  
  <ol>
  <li>"some text"" in the back ground </li>
  <li>"Onload function call"  popup </li>
  <li>"Focus is on current page" pop up . </li>
  </ol>
  
  <p>But I am not getting the pop up "Onload function call"  :( . I need to run the onload event in the body before the focus event. IS it possible to do such a thing ?</p>