title: How to use a onload event in html, to call a function in a js file
body: <p>I have a html file, where I need some items to be loaded from the server, for which I use a function in the js file. Now, instead of having that code in the  tag in the html file, could I have that function in the js file, and call it through a onload attribute on any of the tags in HTML(as soon as the page loads)?</p>
  
  <p>My HTML page is:</p>
  
  <pre><code>&lt;script&gt;
  $.getScript(path + "js/jsfile.js");
  &lt;/script&gt;
  
  &lt;link rel="stylesheet" href="jqueryMobile/jquery.mobile-1.4.5.min.css"&gt;
  &lt;script src="jqueryMobile/jquery-1.11.2.min.js"&gt;&lt;/script&gt;
  &lt;script src="jqueryMobile/jquery.mobile-1.4.5.min.js"&gt;&lt;/script&gt;
  
  &lt;header data-role="header"&gt;
     &lt;a href="#" class="ui-btn ui-icon-back ui-btn-icon-left"
      data-role="button" onclick="currentPage.back();"&gt;Back&lt;/a&gt;
     &lt;!--some header tags were here--&gt;
  &lt;/header&gt;
  
  &lt;div data-role="content" style="padding: 15px" &gt;
     &lt;!--some button tags were here--&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>As soon as this page gets loaded, I need the getColor() function to be executed and get the result fetched into the html page.</p>
  
  <p>My jsfile.js page is:</p>
  
  <pre><code>currentPage = {};
  
  currentPage.init = function() {
    WL.Logger.debug("listofenvironments :: init");
  };
  
  currentPage.back = function(){
    WL.Logger.debug("Login :: back");
    pagesHistory.push(path + "pages/otherpage.html");
    $("#pagePort").load(path + "pages/" + "otherpage.html");
  };
  
  function getColor(){
    //some coding goes on here....
  }
  </code></pre>
  
  <p>I have tried using the onload event on the  tag in my html page, but it is not working. While the currentPage.back() function is working fine.</p>