title: How to get function working with passed element from onClick in HTML <a>?
body: <p>I have a simple HTML website that shows info from JavaScript file which takes data from API. Main function in JavaScript file is: </p>
  
  <pre><code>function mainFunction(param) {
      some code - if param1 then add something to HTML, if param2 then add something else, if paramN something else and so on, based on the data from API
  }
  </code></pre>
  
  <p>What I'm struggling with is... <strong>I want by default to load website with specific parameter</strong> in function so it always shows specific content:</p>
  
  <pre><code>window.onload = function() {
      mainFunction(param1);
  };
  </code></pre>
  
  <p>... unless I click a link:</p>
  
  <pre><code>&lt;a id="someID" href="#" onClick="mainFunction(param2);"&gt;x&lt;/a&gt;
  </code></pre>
  
  <p>on the website - then I want my content on page to change.</p>
  
  <p>However, after clicking that link nothing changes. If I remove:</p>
  
  <pre><code>window.onload = function() {
      mainFunction(param1);
  };
  </code></pre>
  
  <p>then page won't load with <em>default</em> content (blank page) but clicking the link surprisingly works and content do change to what I wanted. Therefore, I'm thinking maybe I can't overwrite parameter which is passed to function in <code>windows.onload</code>? </p>
  
  <p>Ideally I would like to have say... 3 links in the footer of HTML page and each of them would have different <code>onClick</code> with specific parameter (eg. <code>param10</code>, <code>param11</code>, <code>param12</code>) to pass to <code>mainFunction()</code>. Clicking one of them will pass parameter to function and function will return &amp; show specific content on the website. Clicking another will pass different parameter to function and function will return &amp; show specific (but this time different) content on the website. Keep in mind that by default always <code>param1</code> should be loaded on page load because maybe links won't be clicked at all during page visit so change of content won't be necessary. </p>
  
  <p>If there is some more explanation needed (or more code) please do tell me!</p>